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 Oct 6, 2024
1 parent bfa1826 commit c8cf180
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 18 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,17 @@ 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: |
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 }}
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

proxy:
description: 'The proxy server used during the scan'
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.
15 changes: 8 additions & 7 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.

15 changes: 8 additions & 7 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 @@ -29,17 +30,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 @@ -70,10 +71,10 @@ async function run() {
const args = getArgsFromInput(curl.replace('curl ', ''))

debug(`Running vulnapi scan with curl: ${JSON.stringify(args)}`)
await exec('vulnapi scan curl', [...args, ...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 c8cf180

Please sign in to comment.