Skip to content

chore(security): standardize SDLC security baseline - #155

Open
ashu-tosh-kumar wants to merge 1 commit into
developmentfrom
chore/security-baseline
Open

chore(security): standardize SDLC security baseline#155
ashu-tosh-kumar wants to merge 1 commit into
developmentfrom
chore/security-baseline

Conversation

@ashu-tosh-kumar

Copy link
Copy Markdown
Owner

Standardizes this repo against the security baseline shared across all public projects.

Added

  • Dependency Review — PR gate that blocks pull requests introducing known-vulnerable dependencies.
  • OpenSSF Scorecard — supply-chain posture, results in the Security tab.
  • Bandit — Python-specific SAST (complements CodeQL; replaces the Python coverage OSSAR used to provide).
  • Dependabot — added github-actions ecosystem + grouped weekly updates.

Removed

  • .github/workflows/ossar.yml
  • .github/workflows/codeql.yml

These were redundant with CodeQL default setup (live), native secret scanning + push protection, and Dependabot — all enabled at the repo level.

Coverage after this PR

Pillar Tool
SAST CodeQL default setup + Bandit
SCA Dependabot alerts/updates + Dependency Review
Secrets GitHub secret scanning + push protection
Supply chain OpenSSF Scorecard + Dependabot (actions)

🤖 Generated with Claude Code

Align repo with the standardized security baseline across all public
projects:

- Add Dependency Review (PR gate blocking known-vulnerable deps).
- Add OpenSSF Scorecard (supply-chain posture, reports to Security tab).
- Add Bandit Python SAST (Python repos only; replaces OSSAR coverage).
- Dependabot: add github-actions ecosystem + grouped updates.
- Remove redundant/dead workflows (OSSAR, disabled advanced CodeQL,
  gitleaks/npm-audit) now covered by CodeQL default setup, native
  secret scanning + push protection, and Dependabot.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates the Dependabot configuration to group updates and adds tracking for GitHub Actions. The reviewer correctly identified that the Python package ecosystem should be configured as "poetry" instead of "pip" to ensure that Poetry lockfiles are updated properly.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread .github/dependabot.yml
Comment on lines +2 to +7
# - pip ecosystem covers Poetry (pyproject.toml / poetry.lock).
# - github-actions keeps workflow action versions current (supply-chain hardening).
# Updates are grouped to minimize PR noise.
version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
- package-ecosystem: "pip"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Since this project uses Poetry for dependency management (as defined in pyproject.toml), the package-ecosystem should be set to poetry instead of pip. Dependabot has native support for poetry which correctly updates both pyproject.toml and poetry.lock. Using pip will not update the Poetry lockfile properly and may fail.

# - poetry ecosystem covers Poetry (pyproject.toml / poetry.lock).
# - github-actions keeps workflow action versions current (supply-chain hardening).
# Updates are grouped to minimize PR noise.
version: 2
updates:
  - package-ecosystem: "poetry"

@qodo-code-review

Copy link
Copy Markdown

CI Feedback 🧐

A test triggered by this PR failed. Here is an AI-generated analysis of the failure:

Action: build3_9

Failed stage: Install dependencies [❌]

Failed test name: ""

Failure summary:

The action failed during Poetry dependency resolution because the workflow is using Python 3.9.25,
but a required dependency is incompatible with Python 3.9:
- poetry-plugin-export (pinned via
^1.10.0) requires Python <4.0,>=3.10, so it cannot be installed on Python 3.9.25.
- As a result, Poetry
reports version solving failed and the step exits with code 1 (see lines 321-330).

Relevant error logs:
1:  ##[group]Runner Image Provisioner
2:  Hosted Compute Agent
...

106:  git switch -
107:  Turn off this advice by setting config variable advice.detachedHead to false
108:  HEAD is now at ce6a5d3 Merge e460aff904bddc8a7a5404d004ea6d97f6646a80 into 18535854eeadb37954ce4d30b66ab59e850b12a6
109:  ##[endgroup]
110:  [command]/usr/bin/git log -1 --format=%H
111:  ce6a5d35a942ea5ad46d4125878feca81ec15bbe
112:  Node 20 is being deprecated. This workflow is running with Node 24 by default. If you need to temporarily use Node 20, you can set the ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true environment variable. For more information see: https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/
113:  ##[group]Run actions/setup-python@v3
114:  with:
115:  python-version: 3.9
116:  token: ***
117:  ##[endgroup]
118:  Version 3.9 was not found in the local cache
119:  (node:2269) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
120:  (Use `node --trace-deprecation ...` to show where the warning was created)
121:  (node:2269) [DEP0169] DeprecationWarning: `url.parse()` behavior is not standardized and prone to errors that have security implications. Use the WHATWG URL API instead. CVEs are not issued for `url.parse()` vulnerabilities.
122:  Version 3.9 is available for downloading
...

310:  Downloading jaraco.classes-3.4.0-py3-none-any.whl (6.8 kB)
311:  Downloading jaraco_context-6.1.1-py3-none-any.whl (7.0 kB)
312:  Downloading backports.tarfile-1.2.0-py3-none-any.whl (30 kB)
313:  Downloading jaraco_functools-4.4.0-py3-none-any.whl (10 kB)
314:  Downloading more_itertools-10.8.0-py3-none-any.whl (69 kB)
315:  Downloading pycparser-2.23-py3-none-any.whl (118 kB)
316:  Installing collected packages: trove-classifiers, fastjsonschema, distlib, zstandard, zipp, urllib3, typing_extensions, tomlkit, tomli, shellingham, rapidfuzz, pyproject-hooks, pycparser, poetry-core, platformdirs, pkginfo, pbs-installer, packaging, msgpack, more-itertools, jeepney, installer, idna, h11, filelock, crashtest, charset_normalizer, certifi, backports.tarfile, requests, python-discovery, jaraco.functools, jaraco.context, jaraco.classes, importlib-metadata, httpcore, findpython, exceptiongroup, dulwich, cleo, cffi, virtualenv, requests-toolbelt, cryptography, cachecontrol, build, anyio, SecretStorage, httpx, keyring, poetry
317:  Successfully installed SecretStorage-3.3.3 anyio-4.12.1 backports.tarfile-1.2.0 build-1.4.4 cachecontrol-0.14.3 certifi-2026.6.17 cffi-2.0.0 charset_normalizer-3.4.7 cleo-2.1.0 crashtest-0.4.1 cryptography-49.0.0 distlib-0.4.3 dulwich-0.24.10 exceptiongroup-1.3.1 fastjsonschema-2.21.2 filelock-3.19.1 findpython-0.7.1 h11-0.16.0 httpcore-1.0.9 httpx-0.28.1 idna-3.18 importlib-metadata-8.7.1 installer-0.7.0 jaraco.classes-3.4.0 jaraco.context-6.1.1 jaraco.functools-4.4.0 jeepney-0.9.0 keyring-25.7.0 more-itertools-10.8.0 msgpack-1.1.2 packaging-26.2 pbs-installer-2025.12.17 pkginfo-1.12.1.2 platformdirs-4.4.0 poetry-2.2.1 poetry-core-2.2.1 pycparser-2.23 pyproject-hooks-1.2.0 python-discovery-1.4.2 rapidfuzz-3.13.0 requests-2.32.5 requests-toolbelt-1.0.0 shellingham-1.5.4 tomli-2.4.1 tomlkit-0.15.0 trove-classifiers-2026.6.1.19 typing_extensions-4.15.0 urllib3-2.6.3 virtualenv-21.5.1 zipp-3.23.1 zstandard-0.25.0
318:  Using version ^1.10.0 for poetry-plugin-export
319:  Updating dependencies
320:  Resolving dependencies...
321:  The current project's supported Python range (3.9.25) is not compatible with some of the required packages Python requirement:
322:  - poetry-plugin-export requires Python <4.0,>=3.10, so it will not be installable for Python 3.9.25
323:  Because poetry-plugin-export (1.10.0) requires Python <4.0,>=3.10
324:  and no versions of poetry-plugin-export match >1.10.0,<2.0.0, poetry-plugin-export is forbidden.
325:  So, because poetry-instance depends on poetry-plugin-export (^1.10.0), version solving failed.
326:  * Check your dependencies Python requirement: The Python requirement can be specified via the `python` or `markers` properties
327:  For poetry-plugin-export, a possible solution would be to set the `python` property to "<empty>"
328:  https://python-poetry.org/docs/dependency-specification/#python-restricted-dependencies,
329:  https://python-poetry.org/docs/dependency-specification/#using-environment-markers
330:  ##[error]Process completed with exit code 1.
331:  Node 20 is being deprecated. This workflow is running with Node 24 by default. If you need to temporarily use Node 20, you can set the ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true environment variable. For more information see: https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@v2.4.0
branches: ["development"]

# Declare default permissions as read only.
permissions: read-all
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Standardize repo SDLC security baseline (Dependabot, Bandit, Scorecard, Dependency Review)

⚙️ Configuration changes ✨ Enhancement 🕐 10-20 Minutes

Grey Divider

AI Description

• Add Bandit, Dependency Review, and OpenSSF Scorecard security workflows.
• Expand Dependabot to include GitHub Actions with weekly grouped updates.
• Remove redundant OSSAR and advanced CodeQL workflows in favor of GitHub defaults.
Diagram

graph TD
  PR["Pull Request"] --> DepRev["Dependency Review"]
  PR --> Bandit["Bandit (SARIF)"] --> SecTab[("Security tab")]
  Push["Push/Schedule"] --> Score["OpenSSF Scorecard"] --> SecTab
  Dependabot["Dependabot (weekly)"] --> PR
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Use organization-level reusable workflows
  • ➕ Centralizes security baseline maintenance across repositories
  • ➕ Reduces per-repo drift and duplicated workflow logic
  • ➕ Easier bulk upgrades (actions versions, permissions hardening)
  • ➖ Requires shared workflow hosting and versioning strategy
  • ➖ Less flexibility for repo-specific exclusions or schedules
  • ➖ Initial rollout can be more complex than in-repo workflows
2. Make Bandit blocking (fail the job on findings)
  • ➕ Immediate enforcement of Python security rules
  • ➕ Prevents known classes of issues from merging
  • ➖ Higher false-positive risk and potential developer friction
  • ➖ May duplicate CodeQL gating intent if CodeQL is already required
  • ➖ Requires tuning baseline and suppressions to be sustainable

Recommendation: The PR’s approach is a solid baseline: keep Dependency Review as the PR gate, publish Bandit/Scorecard SARIF for visibility, and rely on GitHub’s CodeQL default setup for the primary SAST gate. Consider migrating these workflows to org-level reusable workflows if multiple repos need identical baselines; it improves long-term maintainability without changing the security model.

Files changed (4) +123 / -7

Enhancement (3) +106 / -0
bandit.ymlAdd Bandit SAST workflow with SARIF upload +37/-0

Add Bandit SAST workflow with SARIF upload

• Introduces a Bandit GitHub Actions workflow for Python security scanning on PRs, pushes, and a weekly schedule. Produces SARIF output and uploads results to GitHub code scanning while remaining non-blocking via --exit-zero.

.github/workflows/bandit.yml

dependency-review.ymlAdd Dependency Review PR gate for vulnerable dependency changes +22/-0

Add Dependency Review PR gate for vulnerable dependency changes

• Adds GitHub's dependency-review-action to scan dependency manifest changes in pull requests. Configured to fail on high severity and comment a summary on failure, making it an enforcement gate.

.github/workflows/dependency-review.yml

scorecard.ymlAdd OpenSSF Scorecard workflow and publish results to Security tab +47/-0

Add OpenSSF Scorecard workflow and publish results to Security tab

• Adds scheduled and event-driven OpenSSF Scorecard analysis for supply-chain posture. Publishes results (SARIF) as an artifact and uploads them to GitHub code scanning for visibility in the Security tab.

.github/workflows/scorecard.yml

Other (1) +17 / -7
dependabot.ymlGroup weekly Dependabot updates and add GitHub Actions ecosystem +17/-7

Group weekly Dependabot updates and add GitHub Actions ecosystem

• Refines Dependabot configuration to run weekly, grouped updates for Python dependencies. Adds a second ecosystem for GitHub Actions to keep workflow action versions current and reduces PR noise via grouping.

.github/dependabot.yml

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Security checks skip main 🐞 Bug ⛨ Security
Description
.github/workflows/dependency-review.yml and .github/workflows/bandit.yml only trigger for PRs
targeting development, so pull requests into main won’t run dependency-vulnerability gating or
publish Bandit SARIF results. This creates a security coverage gap because other workflows in this
repo clearly operate on main, indicating it is an active integration/release branch.
Code

.github/workflows/dependency-review.yml[R5-8]

+on:
+  pull_request:
+    branches: ["development"]
+
Evidence
The new security workflows are limited to development, while other repository workflows and
documentation explicitly use main, demonstrating that main PRs are in-scope and would miss these
checks.

.github/workflows/dependency-review.yml[5-8]
.github/workflows/bandit.yml[7-13]
.github/workflows/python-app.yml[6-11]
.github/workflows/docs.yml[3-7]
README.md[54-64]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
Dependency Review and Bandit workflows are configured to run only when the PR target branch is `development`, which leaves `main` PRs without these security checks.

### Issue Context
This repo already runs CI and docs builds on `main`, so `main` appears to be an active branch that should receive the same security baseline coverage.

### Fix Focus Areas
- .github/workflows/dependency-review.yml[5-8]
- .github/workflows/bandit.yml[7-13]

### Suggested change
Update workflow triggers to include both branches, e.g.:
```yaml
on:
 pull_request:
   branches: ["main", "development"]
```
(and similarly for `push` in `bandit.yml`).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Unpinned action refs 🐞 Bug ⛨ Security
Description
The added workflows reference GitHub Actions by mutable version tags (e.g., @v4, @v3) rather
than immutable commit SHAs, which weakens supply-chain integrity if a tag is ever moved/compromised.
This is defense-in-depth hardening and can be addressed without increasing update burden since
Dependabot is configured for github-actions.
Code

.github/workflows/bandit.yml[R24-37]

+      - name: Checkout
+        uses: actions/checkout@v4
+      - name: Set up Python
+        uses: actions/setup-python@v5
+        with:
+          python-version: "3.13"
+      - name: Install Bandit
+        run: pip install "bandit[sarif]"
+      - name: Run Bandit
+        run: bandit -r . -x ./tests,./.venv,./venv -f sarif -o bandit.sarif --exit-zero
+      - name: Upload SARIF to code-scanning
+        uses: github/codeql-action/upload-sarif@v3
+        with:
+          sarif_file: bandit.sarif
Evidence
The workflows added/modified in this PR use tag refs for several actions across Bandit, Dependency
Review, and Scorecard, which is the specific pattern SHA-pinning mitigates.

.github/workflows/bandit.yml[24-37]
.github/workflows/dependency-review.yml[16-22]
.github/workflows/scorecard.yml[25-46]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
Workflows use tag-based action references (e.g., `actions/checkout@v4`) which are not immutable.

### Issue Context
Pinning actions to a full commit SHA is recommended supply-chain hardening; Dependabot (`github-actions` ecosystem) can keep SHA-pins updated automatically.

### Fix Focus Areas
- .github/workflows/bandit.yml[24-37]
- .github/workflows/dependency-review.yml[16-22]
- .github/workflows/scorecard.yml[25-46]

### Suggested change
Replace each `uses: owner/action@vX` with `uses: owner/action@<full_sha>` (optionally keep a comment with the tag), for example:
```yaml
- uses: actions/checkout@<full_sha> # v4
```

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment on lines +5 to +8
on:
pull_request:
branches: ["development"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Security checks skip main 🐞 Bug ⛨ Security

.github/workflows/dependency-review.yml and .github/workflows/bandit.yml only trigger for PRs
targeting development, so pull requests into main won’t run dependency-vulnerability gating or
publish Bandit SARIF results. This creates a security coverage gap because other workflows in this
repo clearly operate on main, indicating it is an active integration/release branch.
Agent Prompt
### Issue description
Dependency Review and Bandit workflows are configured to run only when the PR target branch is `development`, which leaves `main` PRs without these security checks.

### Issue Context
This repo already runs CI and docs builds on `main`, so `main` appears to be an active branch that should receive the same security baseline coverage.

### Fix Focus Areas
- .github/workflows/dependency-review.yml[5-8]
- .github/workflows/bandit.yml[7-13]

### Suggested change
Update workflow triggers to include both branches, e.g.:
```yaml
on:
  pull_request:
    branches: ["main", "development"]
```
(and similarly for `push` in `bandit.yml`).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

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.

2 participants