Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

code improvements

Pedro Ladeirae38b0db3c97c
diff --git a/.deepsec/scripts/list-pr-files.sh b/.deepsec/scripts/list-pr-files.sh
index ccf4ed212c..1e2433a3e2 100755
--- a/.deepsec/scripts/list-pr-files.sh
+++ b/.deepsec/scripts/list-pr-files.sh
@@ -6,7 +6,11 @@ set -euo pipefail
range="${1:?git range required (e.g. origin/main...HEAD)}"
repo_root="$(cd "$(dirname "$0")/../.." && pwd)"
-git -C "$repo_root" diff --name-only --diff-filter=ACMR "$range" -- apps/web \
+files="$(git -C "$repo_root" diff --name-only --diff-filter=ACMR "$range" -- apps/web)"
+
+[ -z "$files" ] && exit 0
+
+printf '%s\n' "$files" \
| sed 's|^apps/web/||' \
| grep -vE '(^|/)(__tests__|e2e|playwright|fixtures|generated|\.next|playwright-report|test-results)/' \
| grep -vE '\.(test|spec)\.(ts|tsx|js|jsx)$' \
diff --git a/.deepsec/scripts/notify-slack.mjs b/.deepsec/scripts/notify-slack.mjs
index 13c0226e3b..6b6b4bc9e1 100644
--- a/.deepsec/scripts/notify-slack.mjs
+++ b/.deepsec/scripts/notify-slack.mjs
@@ -37,7 +37,7 @@ function keep(finding) {
const severity = finding.metadata?.severity ?? finding.severity;
if (!HIGH.has(severity)) return false;
const verdict = finding.metadata?.revalidation?.verdict;
- return !verdict || verdict === "true-positive";
+ return verdict === "true-positive";
}
function titleText(finding) {
diff --git a/.github/workflows/deepsec-pr.yml b/.github/workflows/deepsec-pr.yml
index 519fdbcead..9db6bf31a1 100644
--- a/.github/workflows/deepsec-pr.yml
+++ b/.github/workflows/deepsec-pr.yml
@@ -24,10 +24,13 @@ jobs:
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
+ persist-credentials: false
- name: Fetch PR base
working-directory: .
- run: git fetch origin "${{ github.event.pull_request.base.ref }}"
+ env:
+ PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
+ run: git fetch origin "$PR_BASE_REF"
- name: Setup pnpm
uses: pnpm/action-setup@v4
@@ -46,15 +49,14 @@ jobs:
pnpm install --frozen-lockfile --ignore-workspace
test -x node_modules/.bin/deepsec
- - name: Install Codex CLI
- run: npm install -g @openai/codex
-
- name: List changed apps/web files
id: files
working-directory: .
+ env:
+ PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
run: |
mkdir -p .deepsec
- .deepsec/scripts/list-pr-files.sh "origin/${{ github.event.pull_request.base.ref }}...HEAD" \
+ .deepsec/scripts/list-pr-files.sh "origin/${PR_BASE_REF}...HEAD" \
> .deepsec/pr-files.txt
if [ -s .deepsec/pr-files.txt ]; then
echo "has_files=true" >> "$GITHUB_OUTPUT"
@@ -75,14 +77,14 @@ jobs:
--project-id web \
--files-from pr-files.txt \
--reinvestigate \
- --comment-out "${{ github.workspace }}/comment.md"
+ --comment-out "${{ github.workspace }}/.deepsec/comment.md"
- name: Upload PR comment
- if: always() && hashFiles('comment.md') != ''
+ if: always() && hashFiles('.deepsec/comment.md') != ''
uses: actions/upload-artifact@v4
with:
name: deepsec-comment
- path: comment.md
+ path: .deepsec/comment.md
retention-days: 1
comment:
@@ -109,7 +111,7 @@ jobs:
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
- body: fs.readFileSync('comment.md', 'utf8'),
+ body: fs.readFileSync('.deepsec/comment.md', 'utf8'),
});
- name: Notify Slack
@@ -130,7 +132,12 @@ jobs:
const prUrl = process.env.PR_URL;
const prTitle = (process.env.PR_TITLE || "PR").replace(/[<>&]/g, "");
const prNumber = process.env.PR_NUMBER;
- const findings = fs.readFileSync("comment.md", "utf8").slice(0, 2200);
+ const findings = fs
+ .readFileSync(".deepsec/comment.md", "utf8")
+ .slice(0, 2200)
+ .replaceAll("&", "&amp;")
+ .replaceAll("<", "&lt;")
+ .replaceAll(">", "&gt;");
const text = [
`:alert: DeepSec findings on <${prUrl}|#${prNumber} ${prTitle}>`,
"",
diff --git a/.github/workflows/deepsec.yml b/.github/workflows/deepsec.yml
index eda7d663e8..5daee95141 100644
--- a/.github/workflows/deepsec.yml
+++ b/.github/workflows/deepsec.yml
@@ -88,7 +88,7 @@ jobs:
--out ./findings
- name: Notify Slack
- if: ${{ !cancelled() }}
+ if: ${{ !cancelled() && steps.process.outcome == 'success' && steps.revalidate.outcome == 'success' }}
env:
DEEPSEC_SLACK_HOOK: ${{ secrets.DEEPSEC_SLACK_HOOK }}
run: pnpm notify-slack findings.json