Add security workflows pre-commit hooks, dependency review, CodeQL#196
Add security workflows pre-commit hooks, dependency review, CodeQL#196rahuldevikar761 wants to merge 2 commits intomainfrom
Conversation
…or JavaScript/TypeScript
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Files
|
There was a problem hiding this comment.
Pull request overview
This PR introduces baseline security automation for the Agent365 Node.js monorepo by adding local pre-commit checks and GitHub security scanning workflows.
Changes:
- Add a
.pre-commit-config.yamlwith gitleaks, whitespace/YAML/JSON checks, plus eslint and prettier hooks. - Add a GitHub Actions “Dependency Review” workflow to block vulnerable or disallowed-license dependency changes in PRs.
- Add a GitHub Actions CodeQL workflow to run JS/TS security analysis on pushes, PRs, and a weekly schedule.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
.pre-commit-config.yaml |
Introduces pre-commit hooks for secrets scanning, formatting, and linting. |
.github/workflows/dependency-review.yml |
Adds PR-time dependency vulnerability/license review. |
.github/workflows/codeql.yml |
Adds CodeQL scanning for JS/TS on main/PR/schedule. |
| - repo: https://github.com/pre-commit/mirrors-prettier | ||
| rev: v4.0.0-alpha.8 | ||
| hooks: | ||
| - id: prettier | ||
| types_or: [javascript, typescript, json, yaml, markdown] |
There was a problem hiding this comment.
The prettier hook is pinned to an alpha release (v4.0.0-alpha.8). Using prerelease formatter versions can cause unexpected formatting churn and makes it harder to keep contributors in sync. Consider pinning to the latest stable prettier (or aligning with a repo-managed prettier dependency if/when one is added).
.github/workflows/codeql.yml
Outdated
| - name: Autobuild | ||
| uses: github/codeql-action/autobuild@v3 | ||
|
|
There was a problem hiding this comment.
The CodeQL job uses the generic Autobuild step but doesn’t set up pnpm or install dependencies. This repo uses pnpm and pnpm-specific dependency specifiers (e.g., "catalog:"), so an npm-based autobuild/install can fail, and a pnpm-based build won’t run unless pnpm is installed. Prefer installing pnpm (pnpm/action-setup) and running pnpm i + the repo build, or configure CodeQL to skip the build step if you intentionally want buildless analysis.
| - name: Autobuild | |
| uses: github/codeql-action/autobuild@v3 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9 | |
| run_install: false | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Build project | |
| run: pnpm run build --if-present |
| - eslint@9.5.0 | ||
| - typescript | ||
| - "@typescript-eslint/parser" | ||
| - "@typescript-eslint/eslint-plugin" |
There was a problem hiding this comment.
The eslint pre-commit hook is running in an isolated pre-commit environment but the repo’s eslint.config.mjs imports modules that aren’t listed under additional_dependencies (e.g., "@eslint/js" and "typescript-eslint"). As-is, the hook is likely to fail with module-not-found errors. Consider either adding the missing dependencies (and pinning them to the repo’s versions) or switching to a local hook that runs the workspace’s pnpm-managed eslint.
| - "@typescript-eslint/eslint-plugin" | |
| - "@typescript-eslint/eslint-plugin" | |
| - "@eslint/js" | |
| - "typescript-eslint" |
.pre-commit-config.yaml
Outdated
| rev: v9.5.0 | ||
| hooks: | ||
| - id: eslint | ||
| files: \.[jt]sx?$ | ||
| types: [file] | ||
| additional_dependencies: | ||
| - eslint@9.5.0 |
There was a problem hiding this comment.
The pre-commit config pins eslint to v9.5.0, but the repo currently uses eslint ^9.39.1 (and matching @typescript-eslint versions). This version skew can lead to different lint results locally vs CI. It’s better to align the pre-commit hook’s eslint/@typescript-eslint versions with the repo’s devDependencies (or run the repo’s eslint via pnpm).
| rev: v9.5.0 | |
| hooks: | |
| - id: eslint | |
| files: \.[jt]sx?$ | |
| types: [file] | |
| additional_dependencies: | |
| - eslint@9.5.0 | |
| rev: v9.39.1 | |
| hooks: | |
| - id: eslint | |
| files: \.[jt]sx?$ | |
| types: [file] | |
| additional_dependencies: | |
| - eslint@9.39.1 |
c6b55cb to
51bfb7b
Compare
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| dependency-review: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Dependency Review | ||
| uses: actions/dependency-review-action@v4 | ||
| with: | ||
| fail-on-severity: high | ||
| comment-summary-in-pr: always | ||
| deny-licenses: GPL-3.0-only, AGPL-3.0-only |
There was a problem hiding this comment.
The workflow grants pull-requests: write and forces comment-summary-in-pr: always. If PR-commenting isn’t strictly required, consider dropping to pull-requests: read (principle of least privilege). If commenting is required, ensure this won’t break on PRs from forks where GITHUB_TOKEN typically can’t write PR comments (e.g., make commenting conditional or switch to a safer reporting mode).
| # Dependency Review - blocks PRs that introduce known-vulnerable dependencies | ||
| name: Dependency Review |
There was a problem hiding this comment.
PR title mentions adding CodeQL, but there’s no CodeQL workflow currently under .github/workflows (only CI and dependency-review). Either add the CodeQL workflow in this PR or adjust the PR title/description to match what’s actually being introduced.
| on: | ||
| pull_request: | ||
| branches: [main] |
There was a problem hiding this comment.
This workflow only runs for PRs targeting main, but the existing CI workflow is configured for both main and master. If master is still a supported target branch in this repo, dependency review will be skipped for those PRs—consider including master here as well (or remove master from CI if it’s no longer used).
| # Pre-commit hooks for Agent365-nodejs | ||
| # Install: pip install pre-commit && pre-commit install | ||
| # Run manually: pre-commit run --all-files |
There was a problem hiding this comment.
This new file appears to use CRLF line endings (e.g., lines match ...prettier\r). The repo’s .editorconfig requires end_of_line = lf, so please normalize this file to LF to avoid noisy diffs and formatting churn across platforms.
| # Dependency Review - blocks PRs that introduce known-vulnerable dependencies | ||
| name: Dependency Review | ||
|
|
There was a problem hiding this comment.
This workflow file appears to be committed with CRLF line endings (e.g., uses: ...@v4\r). The repo’s .editorconfig requires LF, so please normalize this file to LF to prevent cross-platform churn.
No description provided.