-
Notifications
You must be signed in to change notification settings - Fork 5
Add coverage junit input runid output #45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
ba09836
Update action.yml
vlussenburg 4425e97
added logic in main for junit + coverage
unionfindbee 90ff1ff
added ci for the mcode action
vlussenburg 44c93de
added test for new functionality
vlussenburg c0ae39a
Add Mayhemfile for testing
vlussenburg e1b1f81
Update main.yml
vlussenburg a4dcf18
new build
vlussenburg 2676788
Update main.yml
vlussenburg 0c0fd5d
Update main.ts
vlussenburg 0aba2a5
formatting
vlussenburg d6dc325
build
vlussenburg 59cc9b5
Update main.yml
vlussenburg fbb1f21
Update main.yml
vlussenburg 90b0715
Update main.yml
vlussenburg e5c8fcb
Update main.ts
vlussenburg 3f74adc
build
vlussenburg 0996e01
Update package.json
vlussenburg 32df2cc
Update package.json
vlussenburg 823c391
deps and build
vlussenburg c81836c
Update action.yml
vlussenburg 7af55d3
Update action.yml
vlussenburg b6999a5
Update action.yml
vlussenburg eb807a7
added run output
vlussenburg 13dcea1
try out output
vlussenburg 265e40e
another test
vlussenburg 2c11ef4
Update action.yml
vlussenburg 2a42b1a
Update README.md
vlussenburg ceadeb2
Update main.yml
vlussenburg a322862
Update README.md
vlussenburg d88c449
Update action.yml
vlussenburg 65cea5a
Create dependabot.yml
vlussenburg ac7b206
Merge pull request #44 from vlussenburg/main
vlussenburg 4e4c296
bug when coverage input not inputted
unionfindbee 7583d20
-z
unionfindbee 06a8f8a
-z order
unionfindbee 18b936d
-z order
unionfindbee 75ba015
yarn build
unionfindbee d40bfe1
if statement bug
unionfindbee 0979f44
if statement bug
unionfindbee a50957d
if statement bug
unionfindbee 6efec39
if statement bug
unionfindbee ef420c6
if statement bug
unionfindbee 886f84f
remove echo
unionfindbee c37af24
added missing semicolons, added logging, skipping wait if user did no…
vlussenburg 03065e0
build
vlussenburg 068bfe8
Update main.yml
vlussenburg bb74a6f
Update main.yml
vlussenburg dccdccb
Update main.yml
vlussenburg 3d596a6
Update main.yml
vlussenburg c073689
Update main.yml
vlussenburg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| version: 2 | ||
| updates: | ||
| # Enable version updates for npm | ||
| - package-ecosystem: 'npm' | ||
| # Look for `package.json` and `lock` files in the `root` directory | ||
| directory: '/' | ||
| # Check the npm registry for updates every day (weekdays) | ||
| schedule: | ||
| interval: 'daily' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| name: 'build-test' | ||
| on: | ||
| push | ||
|
|
||
| jobs: | ||
| build: # make sure build/ci work properly | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| MAYHEM_TOKEN: ${{ secrets.MAYHEM_TOKEN }} | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| with: | ||
| # fetch entire history to compute diffs between jobs | ||
| fetch-depth: 0 | ||
| - run: | | ||
| npm install | ||
| - run: | | ||
| npm run all | ||
|
|
||
| test-some-outputs: # make sure the action works on a clean machine without building | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| with: | ||
| # fetch entire history to compute diffs between jobs | ||
| fetch-depth: 0 | ||
|
|
||
| - uses: ./ | ||
| id: mcode-action | ||
| with: | ||
| mayhem-url: https://demo.forallsecure.com | ||
| mayhem-token: ${{ secrets.MAYHEM_TOKEN }} | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| sarif-output: out/sarif/ | ||
| args: --image forallsecure/lighttpd:vulnerable --file __tests__/Mayhemfile --duration 60 | ||
|
|
||
| - name: Upload SARIF file(s) | ||
| uses: github/codeql-action/upload-sarif@v2 | ||
| with: | ||
| sarif_file: out/sarif | ||
|
|
||
| - name: Print runId (${{ steps.mcode-action.outputs.runId }}) and test it's non-empty | ||
| run: | | ||
| [ -z "${{ steps.mcode-action.outputs.runId }}" ] && echo "runId was blank!" && exit 1; | ||
| echo "The run id was: ${{ steps.mcode-action.outputs.runId }}" | ||
|
|
||
| test-all-outputs: # make sure the action works on a clean machine without building | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| with: | ||
| # fetch entire history to compute diffs between jobs | ||
| fetch-depth: 0 | ||
|
|
||
| - uses: ./ | ||
| id: mcode-action | ||
| with: | ||
| mayhem-url: https://demo.forallsecure.com | ||
| mayhem-token: ${{ secrets.MAYHEM_TOKEN }} | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| junit-output: out/junit/ | ||
| sarif-output: out/sarif/ | ||
| coverage-output: out/coverage/ | ||
| args: --image forallsecure/lighttpd:vulnerable --file __tests__/Mayhemfile --duration 60 | ||
|
|
||
| - name: Archive Coverage report | ||
| uses: actions/upload-artifact@v3 | ||
| with: | ||
| name: coverage-report | ||
| path: out/coverage/ | ||
|
|
||
| - name: Archive JUnit results | ||
| uses: actions/upload-artifact@v3 | ||
| with: | ||
| name: mcode-junit | ||
| path: out/junit/ | ||
|
|
||
| - name: Upload SARIF file(s) | ||
| uses: github/codeql-action/upload-sarif@v2 | ||
| with: | ||
| sarif_file: out/sarif | ||
|
|
||
| - name: Print runId (${{ steps.mcode-action.outputs.runId }}) and test it's non-empty | ||
| run: | | ||
| [ -z "${{ steps.mcode-action.outputs.runId }}" ] && echo "runId was blank!" && exit 1; | ||
| echo "The run id was: ${{ steps.mcode-action.outputs.runId }}" | ||
vlussenburg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| test-no-outputs: # make sure the action works on a clean machine without building | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| with: | ||
| # fetch entire history to compute diffs between jobs | ||
| fetch-depth: 0 | ||
|
|
||
| - uses: ./ | ||
| id: mcode-action | ||
| with: | ||
| mayhem-url: https://demo.forallsecure.com | ||
| mayhem-token: ${{ secrets.MAYHEM_TOKEN }} | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| args: --image forallsecure/lighttpd:vulnerable --file __tests__/Mayhemfile --duration 60 | ||
|
|
||
| - name: Print runId (${{ steps.mcode-action.outputs.runId }}) and test it's non-empty | ||
| run: | | ||
| [ -z "${{ steps.mcode-action.outputs.runId }}" ] && echo "runId was blank!" && exit 1; | ||
| echo "The run id was: ${{ steps.mcode-action.outputs.runId }}" | ||
vlussenburg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| image: forallsecure/lighttpd:vulnerable # fields are unnecessary | ||
| duration: 60 # since they will | ||
| project: forallsecure/lighttpd # be filled at | ||
| target: lighttpd # run creation time | ||
| advanced_triage: true | ||
| tasks: | ||
| - name: exploitability_factors | ||
| - name: regression_testing | ||
| - name: behavior_testing | ||
| - name: coverage_analysis | ||
| cmds: | ||
| - cmd: /usr/local/sbin/lighttpd -D -f /usr/local/etc/lighttpd.conf | ||
| network: | ||
| url: tcp://localhost:80 | ||
| timeout: 2 | ||
| client: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "pull_request": { | ||
| "head": { | ||
| "ref": "sample-head-ref", | ||
| "sha": "abcdef1234567890" | ||
| }, | ||
| "base": { | ||
| "ref": "sample-base-ref" | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,46 @@ | ||
| import * as process from "process"; | ||
| import { ExecFileSyncOptions, execFileSync } from "child_process"; | ||
| import * as path from "path"; | ||
| import fs from "fs"; | ||
|
|
||
| // shows how the runner will run a javascript action with env / stdout protocol | ||
| test("test runs", () => { | ||
| process.env["GITHUB_REPOSITORY"] = "ForAllSecure/mapi-action"; | ||
| process.env["GITHUB_REPOSITORY"] = "ForAllSecure/mcode-action"; | ||
| process.env["GITHUB_SERVER_URL"] = "https://github.com"; | ||
| process.env["GITHUB_RUN_ID"] = "14"; | ||
| process.env["GITHUB_EVENT_PATH"] = "__tests__/events.json"; | ||
| process.env["RUNNER_TEMP"] = "/tmp"; | ||
| process.env["RUNNER_TOOL_CACHE"] = "/tmp"; | ||
| process.env["INPUT_MAPI-TOKEN"] = process.env.MAPI_TOKEN; | ||
|
|
||
| process.env["INPUT_MAYHEM-TOKEN"] = process.env.MAYHEM_TOKEN; | ||
| process.env["INPUT_DURATION"] = "10"; | ||
| process.env["INPUT_API-URL"] = | ||
| "https://demo-api.mayhem4api.forallsecure.com/api/v3"; | ||
| process.env["INPUT_API-SPEC"] = | ||
| "https://demo-api.mayhem4api.forallsecure.com/api/v3/openapi.json"; | ||
| process.env["INPUT_GITHUB-TOKEN"] = "12123123321312"; | ||
|
|
||
| process.env["INPUT_JUNIT-OUTPUT"] = "junit-output"; | ||
| process.env["INPUT_SARIF-OUTPUT"] = "sarif-output"; | ||
| process.env["INPUT_COVERAGE-OUTPUT"] = "coverage-output"; | ||
|
|
||
| const np = process.execPath; | ||
| const ip = path.join(__dirname, "..", "lib", "main.js"); | ||
| const options: ExecFileSyncOptions = { | ||
| env: process.env, | ||
| }; | ||
| try { | ||
| execFileSync(np, [ip], options); | ||
| throw new Error("Actions should have failed due to finding a bug"); | ||
| console.log(execFileSync(np, [ip], options).toString()); | ||
| } catch (error: any) { | ||
| if (error.stdout === undefined) { | ||
| throw error; | ||
| } | ||
| expect(error.stdout.toString()).toEqual( | ||
| expect.stringContaining("Fuzzing complete!,") | ||
| ); | ||
| expect(error.stdout.toString()).toEqual( | ||
| expect.stringContaining("Found internal-server-error!") | ||
| ); | ||
| expect(error.stdout.toString()).toEqual( | ||
| expect.stringContaining("The Mayhem for API scan found issues in the API") | ||
| ); | ||
| // Ignore the error. We known the Mayhemfile doesn't exists right now, so the bash script fails. | ||
| //console.log(error); | ||
| } | ||
|
|
||
| if (!fs.existsSync("junit-output")) { | ||
| throw new Error("Output dir should exist but didn't"); | ||
| } | ||
|
|
||
| if (!fs.existsSync("sarif-output")) { | ||
| throw new Error("Output dir should exist but didn't"); | ||
| } | ||
|
|
||
| if (!fs.existsSync("coverage-output")) { | ||
| throw new Error("Output dir should exist but didn't"); | ||
| } | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.