Skip to content

Commit 7268f9e

Browse files
Justin GolanowskiJustin Golanowski
authored andcommitted
adding sast-sca
1 parent 501e175 commit 7268f9e

File tree

2 files changed

+119
-0
lines changed

2 files changed

+119
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# This workflow is used to run CodeQL analysis on the codebase.
2+
# If a code scanning alert is found, it will fail the PR,
3+
# and prompt the user to fix the issue in a comment.
4+
5+
name: "CodeQL Analysis"
6+
on:
7+
push:
8+
branches:
9+
- master
10+
pull_request:
11+
branches:
12+
- master
13+
schedule:
14+
- cron: "0 0 * * *"
15+
jobs:
16+
analyze-code:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
actions: read
20+
contents: read
21+
security-events: write
22+
pull-requests: write
23+
strategy:
24+
matrix:
25+
languages: [javascript-typescript]
26+
fail-fast: false
27+
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
32+
- name: Initialize CodeQL
33+
uses: github/codeql-action/init@v3
34+
with:
35+
languages: ${{ matrix.languages }}
36+
queries: security-extended
37+
38+
- name: Autobuild
39+
uses: github/codeql-action/autobuild@v3
40+
41+
- name: Analyze
42+
uses: github/codeql-action/analyze@v3
43+
with:
44+
category: "/language:${{ matrix.languages}}"
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Dependency Review Action
2+
3+
# PRs introducing NEW known-vulnerable packages will be blocked from merging.
4+
# This will output a GHAS comment in the PR with the details of the vulnerabilities.
5+
# and will also provide a comment on what to do next.
6+
7+
# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
8+
name: "Dependency review"
9+
on:
10+
pull_request:
11+
branches: ["master"]
12+
13+
permissions:
14+
contents: read
15+
pull-requests: write # Required for PR comments
16+
17+
jobs:
18+
dependency-review:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
vulnerable-changes: ${{ steps.review.outputs.vulnerable-changes }}
22+
steps:
23+
- name: "Checkout repository"
24+
uses: actions/checkout@v4
25+
- name: "Dependency Review"
26+
id: review
27+
uses: actions/dependency-review-action@v4
28+
with:
29+
comment-summary-in-pr: always
30+
fail-on-severity: moderate
31+
#allow-ghsas: GHSA-q34m-jh98-gwm2,GHSA-f9vj-2wh5-fj8j EXAMPLE of how to whitelist!
32+
33+
dependency-review-failure-info:
34+
needs: dependency-review
35+
if: failure()
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Add PR Comment
39+
uses: actions/github-script@v7
40+
env:
41+
VULN_OUTPUT: ${{ needs.dependency-review.outputs.vulnerable-changes }}
42+
with:
43+
script: |
44+
try {
45+
const vulnData = JSON.parse(process.env.VULN_OUTPUT || '[]');
46+
let details = '';
47+
48+
for (const pkg of vulnData) {
49+
details += `\n📦 **${pkg.name}@${pkg.version}**\n`;
50+
}
51+
52+
const comment = `⚠️ **Security Dependency Review Failed** ⚠️
53+
54+
This pull request introduces dependencies with security vulnerabilities of moderate severity or higher.
55+
56+
### Vulnerable Dependencies:${details}
57+
58+
### What to do next?
59+
1. Review the vulnerability details in the Dependency Review Comment above, specifically the "Vulnerabilities" section
60+
2. Click on the links in the "Vulnerability" section to see the details of the vulnerability
61+
3. If multiple versions of the same package are vulnerable, please update to the common latest non-vulnerable version
62+
4. If you are unsure about the vulnerability, please contact the security engineer
63+
5. If the vulnerability cannot be avoided (can't upgrade, or need to keep), contact #security on slack to **get it added to the allowlist**
64+
\nSecurity Engineering contact: #security on slack`;
65+
66+
await github.rest.issues.createComment({
67+
issue_number: context.issue.number,
68+
owner: context.repo.owner,
69+
repo: context.repo.repo,
70+
body: comment
71+
});
72+
} catch (error) {
73+
console.error('Error processing vulnerability data:', error);
74+
throw error;
75+
}

0 commit comments

Comments
 (0)