Skip to content
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

refactor: replacing-check-with-scan #666

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions check-vulnerabilities/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -328,21 +328,24 @@ runs:
- name: "Download the list of ignored safety vulnerabilities"
shell: bash
run: |
wget https://raw.githubusercontent.com/ansys/actions/main/check-vulnerabilities/ignored-safety.txt
FILE='.safety-policy.yml'
if [ -f $FILE ]; then
echo "File $FILE exists."
else
URL_FILE='https://raw.githubusercontent.com/ansys/actions/main/check-vulnerabilities/default_safety_policy.yaml'
echo "File $FILE does not exist."
echo "Using a default policy file from $URL_FILE"
wget $URL_FILE
mv default_safety_policy.yaml $FILE
fi

- name: "Run safety and bandit"
shell: bash
run: |
${{ env.ACTIVATE_VENV }}
# Load accepted safety vulnerabilities
mapfile ignored_safety_vulnerabilities < ignored-safety.txt
ignored_vulnerabilities=''
for pckg in ${ignored_safety_vulnerabilities[*]}; do ignored_vulnerabilities+="-i $pckg "; done
ignored_safety_vulnerabilities=${ignored_safety_vulnerabilities::-1}
echo "Ignored safety vulnerabilities: $ignored_vulnerabilities"

# Run security tools
safety check -o bare --save-json info_safety.json --continue-on-error $ignored_vulnerabilities
safety scan --output screen --save-as json info_safety.json || echo "Running 'safety' failed."
bandit -r ${{ inputs.source-directory }} -o info_bandit.json -f json --exit-zero

- name: "Run safety advisory checks"
Expand Down
41 changes: 41 additions & 0 deletions check-vulnerabilities/default_safety_policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
version: '3.0'

scanning-settings:
max-depth: 6
exclude:
- "node_modules"
- "lib/other/**"
- "**/*.js"
Comment on lines +3 to +8
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, not sure if should add something else here. I thought about the venv folders, but presumable, those are covered below under the python section?

Anyway, if anyone have suggestions, I'm happy to heard them. :)


report:
dependency-vulnerabilities:
enabled: true
auto-ignore-in-report:
python:
environment-results: true
unpinned-requirements: true
cvss-severity: []
vulnerabilities:
52495:
reason: We are not considering this vulnerability for the moment.
expires: '2026-02-01'
62044:
reason: We are not considering this vulnerability for the moment.
expires: '2026-02-01'
67599:
reason: We are not considering this vulnerability for the moment.
expires: '2026-02-01'

fail-scan-with-exit-code:
dependency-vulnerabilities:
enabled: true
fail-on-any-of:
cvss-severity:
- critical
- high
- medium

security-updates:
dependency-vulnerabilities:
auto-security-updates-limit:
- patch
3 changes: 0 additions & 3 deletions check-vulnerabilities/ignored-safety.txt

This file was deleted.

Loading