Skip to content

Commit

Permalink
fix: add double quote around curl args
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelgautier committed Jan 2, 2025
1 parent e139efd commit 381e99c
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 24 deletions.
21 changes: 16 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,17 @@ jobs:
run: |
docker run -d -p 8080:8080 ${{ env.DOCKER_IMAGE }}
sleep 5
curl --verbose http://localhost:8080
curl --verbose http://localhost:8080 -H "Authorization: Bearer ${{ steps.get-jwt.outputs.jwt }}"
- name: Test CURL Local Action
- name: Test cURL Local Action
uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
scans: jwt.*
curl: |
curl http://localhost:8080 -H "Authorization: Bearer ${{ steps.get-jwt.outputs.jwt }}"
http://localhost:8080 -H "Authorization: Bearer ${{ steps.get-jwt.outputs.jwt }}"
- name: Check for vulnerabilities
if: ${{ success() }}
Expand Down Expand Up @@ -139,14 +140,24 @@ jobs:
sleep 5
curl --verbose http://localhost:8080 -H "Authorization: Bearer ${{ steps.get-jwt.outputs.jwt }}"
- name: Test cURL Local Action
- name: Test cURL Local Action with rate limit and excluded scans
uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
rateLimit: 1000/s
excludeScans: discover.*
curl: |
http://localhost:8080 -H "Authorization: Bearer ${{ steps.get-jwt.outputs.jwt }}"
- name: Test cURL Local Action with selected scans
uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
scans: jwt.*
curl: |
curl http://localhost:8080 -H "Authorization: Bearer ${{ steps.get-jwt.outputs.jwt }}"
http://localhost:8080 -H "Authorization: Bearer ${{ steps.get-jwt.outputs.jwt }}"
- name: Test cURL Local Action without Telemetry
uses: ./
Expand All @@ -155,7 +166,7 @@ jobs:
with:
scans: jwt.*
curl: |
curl http://localhost:8080 -H "Authorization: Bearer ${{ steps.get-jwt.outputs.jwt }}"
http://localhost:8080 -H "Authorization: Bearer ${{ steps.get-jwt.outputs.jwt }}"
telemetry: false

# - name: Test OpenAPI Local Action
Expand Down
1 change: 0 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ inputs:
rateLimit:
description: 'The rate limit used to run API vulnerability scans'
required: false
default: 10/s

telemetry:
description:
Expand Down
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 11 additions & 8 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

19 changes: 11 additions & 8 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ const { installVersion } = require('./installer')

function getArgsFromInput(input) {
const inputArgs = parseArgs(input)
debug(`Parsed input args: ${JSON.stringify(inputArgs)}`)
return Object.entries(inputArgs).flatMap(([key, value]) => {
if (key === '_') {
return value
}

if (key.length === 1) {
return `-${key} ${value}`
return `-${key} "${value}"`
}

return `--${key}=${value}`
return `--${key}="${value}"`
})
}

Expand All @@ -34,17 +35,17 @@ function getCommonArgs() {

const scans = getInput('scans')
if (scans) {
commonArgs.push(`--scans=${scans}`)
commonArgs.push(`--scans="${scans}"`)
}

const excludeScans = getInput('excludeScans')
if (excludeScans) {
commonArgs.push(`--exclude-scans=${excludeScans}`)
commonArgs.push(`--exclude-scans="${excludeScans}"`)
}

const proxy = getInput('proxy')
if (proxy) {
commonArgs.push(`--proxy=${proxy}`)
commonArgs.push(`--proxy="${proxy}"`)
}

const severityThreshold = getInput('severityThreshold')
Expand Down Expand Up @@ -74,11 +75,13 @@ async function run() {
debug(`Parsing curl input: ${curl}`)
const args = getArgsFromInput(curl.replace('curl ', ''))

debug(`Running vulnapi scan with curl: ${JSON.stringify(args)}`)
await exec('vulnapi scan curl', [...args, ...commonArgs])
debug(
`Running vulnapi scan with curl: ${JSON.stringify(args)} ${JSON.stringify(commonArgs)}`
)
await exec('vulnapi', ['scan', 'curl', ...args, ...commonArgs])
} else if (openapi) {
debug(`Running vulnapi scan with openapi: ${openapi}`)
await exec('vulnapi scan openapi', [openapi, ...commonArgs])
await exec('vulnapi', ['scan', 'openapi', openapi, ...commonArgs])
} else {
setFailed('You must provide curl or openapi input')
}
Expand Down

0 comments on commit 381e99c

Please sign in to comment.