Skip to content

Add CodeQL static analysis workflow - #505

Open
Ugooweb wants to merge 1 commit into
Stellar-Ecosystem:mainfrom
Ugooweb:add-codeql-workflow
Open

Add CodeQL static analysis workflow#505
Ugooweb wants to merge 1 commit into
Stellar-Ecosystem:mainfrom
Ugooweb:add-codeql-workflow

Conversation

@Ugooweb

@Ugooweb Ugooweb commented Jul 29, 2026

Copy link
Copy Markdown

Closes #410

Context

Currently, the repository does not have a static analysis workflow in place.

Problem

Without automated static analysis, potential security vulnerabilities and anti-patterns can make their way into the codebase unnoticed. CodeQL is an industry-standard static analysis tool that is free for public repositories.

Proposed Approach

This PR introduces a GitHub Actions workflow that runs CodeQL static analysis on the Node workspaces (JavaScript and TypeScript).

CodeQL is configured to catch common vulnerabilities such as:

  • Code injection
  • Path traversal
  • Unsafe deserialisation patterns

Acceptance Criteria Met

  • CodeQL workflow added for JavaScript/TypeScript.
  • Configured to run on all new Pull Requests.
  • Configured to run on a weekly schedule.
  • Security findings will now automatically appear in the repository's Security tab for triage.

Summary by CodeRabbit

  • Chores
    • Added automated CodeQL security analysis for JavaScript and TypeScript code.
    • Analysis runs on changes to the main branch, pull requests, and weekly scheduled scans.

@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@Ugooweb Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a GitHub Actions CodeQL workflow for JavaScript and TypeScript, triggered on changes to main and weekly, with checkout, initialization, autobuild, and analysis steps.

Changes

CodeQL analysis

Layer / File(s) Summary
CodeQL workflow setup
.github/workflows/codeql.yml
Adds push, pull request, and weekly scheduled triggers; configures restricted permissions, a JavaScript/TypeScript matrix, CodeQL initialization, autobuild, and language-scoped analysis.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding a CodeQL static analysis workflow.
Linked Issues check ✅ Passed The workflow runs CodeQL on JavaScript/TypeScript workspaces on PRs and a weekly schedule, and uploads alerts to the Security tab.
Out of Scope Changes check ✅ Passed The change is limited to the requested CodeQL workflow and does not introduce unrelated code changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/codeql.yml:
- Around line 27-28: Update the actions/checkout@v4 step in the CodeQL workflow
to set persist-credentials to false, preventing the GitHub token from remaining
available during subsequent repository-controlled build steps while preserving
the existing checkout behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d6505107-6034-4f99-b0c8-4ba45ec91052

📥 Commits

Reviewing files that changed from the base of the PR and between a3fd824 and 51ce28a.

📒 Files selected for processing (1)
  • .github/workflows/codeql.yml

Comment on lines +27 to +28
- name: Checkout repository
uses: actions/checkout@v4

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== workflow excerpt =="
if [ -f .github/workflows/codeql.yml ]; then
  nl -ba .github/workflows/codeql.yml | sed -n '1,140p'
else
  fd -a 'codeql\.yml$|.github/workflows' . || true
fi

echo
echo "== checkout call sites =="
rg -n "actions/checkout|persist-credentials|permissions:|permissions:\n|security-events|autopos|autobuild|CodeQL|codeql" .github/workflows/codeql.yml .github/workflows -S || true

echo
echo "== repo changed files/stat =="
git diff --name-only HEAD~1..HEAD || true
git diff --stat HEAD~1..HEAD || true

Repository: Stellar-Ecosystem/lodestar

Length of output: 227


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== workflow excerpt =="
if [ -f .github/workflows/codeql.yml ]; then
  nl -ba .github/workflows/codeql.yml | sed -n '1,180p'
else
  echo "missing .github/workflows/codeql.yml"
  fd -a .github/workflows -x sh -c 'echo "--- $1"; nl -ba "$1" | sed -n "1,180p"' sh {}
fi

echo
echo "== checkout call sites =="
rg -n "actions/checkout|persist-credentials|permissions:|permissions:\n|security-events|autopos|autobuild|CodeQL|codeql" .github/workflows/codeql.yml .github/workflows -S || true

echo
echo "== changed files/stat =="
git diff --name-only HEAD~1..HEAD || true
git diff --stat HEAD~1.. hend

Repository: Stellar-Ecosystem/lodestar

Length of output: 227


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== workflow excerpt =="
if [ -f .github/workflows/codeql.yml ]; then
  cat -n .github/workflows/codeql.yml | sed -n '1,180p'
else
  echo "missing .github/workflows/codeql.yml"
  find .github/workflows -maxdepth 1 -type f -print 2>/dev/null || true
fi

echo
echo "== checkout call sites and relevant workflow keys =="
grep -RInE "actions/checkout|persist-credentials|permissions:|security-events|CodeQL|codeql|autobuild|checkout repository" .github/workflows/codeql.yml .github/workflows 2>/dev/null || true

Repository: Stellar-Ecosystem/lodestar

Length of output: 3102


🌐 Web query:

actions/checkout v4 persist-credentials default true token stored .git/config

💡 Result:

In actions/checkout v4, the persist-credentials input defaults to true [1][2][3]. When set to true (or by default), the action configures the authentication token or SSH key to enable subsequent authenticated Git commands within your workflow steps [1][4]. Regarding where the credentials are stored: - In actions/checkout versions prior to v6, credentials were added directly to the local .git/config file [5][6]. - Starting with actions/checkout v6, the action was updated to improve security by storing credentials in a separate file under $RUNNER_TEMP rather than directly in the repository's .git/config [5][6]. This new approach uses Git's includeIf mechanism to conditionally include the credentials, preventing them from being part of the main Git configuration [7][6]. If you wish to prevent the action from configuring these credentials, you can explicitly set persist-credentials: false in your workflow step [1][4]. This is often recommended for increased security to minimize the exposure of your access token [8].

Citations:


Disable checkout credential persistence.

actions/checkout@v4 persists the GitHub token by default, and this job grants security-events: write before running repository-controlled build steps. Set persist-credentials: false on the checkout step.

Proposed fix
     - name: Checkout repository
       uses: actions/checkout@v4
+      with:
+        persist-credentials: false
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
🧰 Tools
🪛 zizmor (1.28.0)

[warning] 27-28: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/codeql.yml around lines 27 - 28, Update the
actions/checkout@v4 step in the CodeQL workflow to set persist-credentials to
false, preventing the GitHub token from remaining available during subsequent
repository-controlled build steps while preserving the existing checkout
behavior.

Source: Linters/SAST tools

@ritik4ever

Copy link
Copy Markdown
Collaborator

Hi @Ugooweb,

This PR could not be merged because it has merge conflicts with the target branch.

Please resolve the merge conflicts, push the updated changes, and the PR can be reviewed and merged.

Thank you!

@Ugooweb

Ugooweb commented Jul 31, 2026

Copy link
Copy Markdown
Author

Hi @Ugooweb,

This PR could not be merged because it has merge conflicts with the target branch.

Please resolve the merge conflicts, push the updated changes, and the PR can be reviewed and merged.

Thank you!

please check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI: no CodeQL or static analysis

2 participants