Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
112 lines (104 loc) · 3.83 KB
/
Copy pathaction.yml
File metadata and controls
112 lines (104 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: decascan
description: >-
OWASP Top 10 scan (MCP, LLM applications, web) of Python and TypeScript code. Fails the
job on findings and can upload SARIF to GitHub code scanning.
author: cvas22
branding:
icon: shield
color: blue
inputs:
path:
description: Directory or file to scan.
default: "."
standard:
description: >-
Top 10 list(s) to scan against, space separated: auto, all, mcp, llm, web. `auto` detects
them from the code's imports and dependencies.
default: auto
fail-on:
description: Fail the job at this severity or above (critical, high, medium, low, info).
default: high
min-severity:
description: Drop findings below this severity from the report.
default: info
exclude:
description: Extra directory names to skip, space separated.
default: ""
sarif-file:
description: Where to write the SARIF report.
default: decascan.sarif
upload-sarif:
description: >-
Upload the SARIF report to GitHub code scanning. Needs `security-events: write` (plus
`actions: read` on a private repository, where GitHub Code Security must also be enabled), and
is not available to pull requests from forks.
default: "false"
annotations:
description: Also print findings as workflow annotations on the PR and run page.
default: "true"
python-version:
description: Python used to run the scanner (3.10 or newer).
default: "3.12"
version:
description: >-
decascan version to install from PyPI (for example `0.1.0`). Empty installs the copy bundled
with this action, which is the right choice when pinning the action to a tag or commit.
default: ""
outputs:
sarif-file:
description: Path of the SARIF report.
value: ${{ steps.scan.outputs.sarif-file }}
exit-code:
description: "0 clean, 1 findings at or above fail-on, 2 bad invocation."
value: ${{ steps.scan.outputs.exit-code }}
runs:
using: composite
steps:
- uses: actions/setup-python@v7
with:
python-version: ${{ inputs.python-version }}
- name: install decascan
shell: bash
env:
VERSION: ${{ inputs.version }}
run: |
if [ -n "$VERSION" ]; then
python -m pip install --quiet "decascan==$VERSION"
else
python -m pip install --quiet "$GITHUB_ACTION_PATH"
fi
- name: scan
id: scan
shell: bash
env:
SCAN_PATH: ${{ inputs.path }}
STANDARDS: ${{ inputs.standard }}
FAIL_ON: ${{ inputs.fail-on }}
MIN_SEVERITY: ${{ inputs.min-severity }}
EXCLUDES: ${{ inputs.exclude }}
SARIF_FILE: ${{ inputs.sarif-file }}
ANNOTATIONS: ${{ inputs.annotations }}
run: |
# Inputs reach the shell through env vars, never by expression interpolation into the
# script text, so a crafted input cannot inject commands.
args=(--fail-on "$FAIL_ON" --min-severity "$MIN_SEVERITY")
for s in $STANDARDS; do args+=(--standard "$s"); done
for e in $EXCLUDES; do args+=(--exclude "$e"); done
# The SARIF run decides the exit code. Annotations come from a second pass with --no-fail;
# scans take seconds and run offline, so rendering twice beats a second output flag.
set +e
decascan scan "$SCAN_PATH" "${args[@]}" -o sarif -f "$SARIF_FILE"
code=$?
set -e
if [ "$ANNOTATIONS" = "true" ]; then
decascan scan "$SCAN_PATH" "${args[@]}" -o github --no-fail
fi
echo "sarif-file=$SARIF_FILE" >> "$GITHUB_OUTPUT"
echo "exit-code=$code" >> "$GITHUB_OUTPUT"
exit "$code"
- name: upload SARIF
if: ${{ always() && inputs.upload-sarif == 'true' && hashFiles(inputs.sarif-file) != '' }}
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: ${{ inputs.sarif-file }}
category: decascan