-
Notifications
You must be signed in to change notification settings - Fork 4
Inherit from gov-codejson with tests #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repo | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: 'npm' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Run tests | ||
| run: npm run test |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 days ago
To fix the problem, add an explicit permissions block that limits the GITHUB_TOKEN to only what this workflow needs. This job only checks out code and runs tests, so it only needs read access to repository contents.
The best targeted fix is to add a permissions section to the test job, directly under runs-on: ubuntu-latest. This keeps the scope local to this job and does not affect any other workflows or jobs. The block should set contents: read, which is the minimal permission required for actions/checkout and read-only operations.
Concretely, in .github/workflows/test.yml, between lines 11 and 13, insert:
permissions:
contents: readNo imports or other definitions are required, as this is standard GitHub Actions YAML configuration.
-
Copy modified lines R12-R13
| @@ -9,6 +9,8 @@ | ||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
|
|
||
| steps: | ||
| - name: Checkout repo |
Problem
The Zod validation schema was manually maintained, requiring us to keep it in sync with the gov-codejson schema. This created drift between our logic and the upstream, and added ongoing maintenance burden whenever the schema changed.
Solution
Replaced the manual schema with an auto-generated one
Result
Schema validation now stays in sync with the gov-codejson, eliminating drift between codebase and upstream changes. This reduces the maintenance burden when schema updates occur since regenerating the types is now a single command
How to Test
Run the schema generator
npx ts-node src/scripts/generate-schema.tsRun the unit tests
npm test