Repository navigation
feat: code scanning with CodeQL, and secret scanning as a setting - #65
Merged
Merged
Conversation
modules.autoupdate with `github.workflows.source: local` gives the repository its own copy of repokeeper-update.yml, read from the installed package. The file was missing from the package's `files`, so that copy could not be read: it worked from a checkout of this repository and would have failed from npm. A test now checks that every reusable workflow a repository can be given a copy of is covered by `files`.
repokeeper set up no scanning of any kind, and its README said so. modules.security, off unless asked for, writes .github/workflows/security.yml. Its codeql job calls the new reusable workflow codeql.yml on every pull request, on every push to the default branch and once a week. The languages come from the stacks: node, python, java, dotnet, ruby and rust are read from source, go and kotlin are built by CodeQL itself, and the workflow files are always analyzed too. Dart, PHP and scripts have no CodeQL language. github.security takes secret_scanning and secret_scanning_push_protection, which `repokeeper github apply` reads and sets like the Dependabot switches. When GitHub refuses, its answer is reported with what a private repository needs. No preset switches either on: both are free on a public repository and paid on a private one, where a preset would leave a failing workflow behind. On GitLab the module writes nothing and says what does the work there. workflow-tests runs codeql.yml on a language read from source and on one that is built, without uploading the fixtures' findings.
# Conflicts: # package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two things the README said repokeeper did not set up.
Code scanning:
modules.security: truewrites.github/workflows/security.yml:It runs on every pull request, on every push to the default branch and once a week. The languages come from the stacks:
nodejavascript-typescriptpythonpythonjavajava-kotlinkotlinjava-kotlinautobuilddotnetcsharpgogoautobuildrubyrubyrustrustdart,php,scriptThe workflow files are always analyzed too (
actions). The identifiers and the build modes were checked against GitHub's documentation and the action's ownaction.yml, not written from memory: Java, C# and Rust are read from source, Kotlin and Go need a build.Secret scanning:
github.security.secret_scanningandsecret_scanning_push_protection, read and set byrepokeeper github applylike the Dependabot switches. When GitHub refuses (a private repository without Secret Protection), its answer is reported with what is missing.Decisions to check
init --preset stricton a private repository would otherwise leave a workflow that fails on every push, and agithub applythat stops at a 422. Sosecurityis a switch to ask for, likeautoupdate, andinitsays once, when it writes the workflow, what a private repository needs. If strict should carry it anyway, it is a small change (the playground's strict has to follow, since a test compares them character for character).include:, a list the project shares with repokeeper, and nothing here manages part of a list yet.checksays so and names the templates. The same line feat: open a pull request when the standard has moved #62 drew forautoupdate.SECURITY_NEEDS_VERSIONin the playground is0.9.0, which is right if this is merged before 0.9.0 is released. If 0.9.0 goes out first, it has to say0.10.0.How
src/modules/security.ts,PlatformAdapter.codeScanning,CODEQL_LANGUAGESinplatforms/github.ts(a line per stack,nullfor a stack CodeQL cannot analyze, so that a new stack has to say)..github/workflows/codeql.yml: one job per language,initandanalyzeofgithub/codeql-actionpinned by SHA at v4.38.3, inputuploadfor callers that must not create alerts.security.ymland the reusable workflowcodeql.yml: two names, so that a repository that keeps its own copies (and this repository itself) can have both.github/settings.ts: the two switches fromsecurity_and_analysisof the repository.Tested
test/modules-security.test.ts, 9), the settings (test/github-secret-scanning.test.ts, 6), the notes (test/report-security.test.ts, 3), the reusable workflow and its job inworkflow-tests(test/workflows.test.ts). 457 tests in all,typecheck,lint,build,npm run standard.npm pack, the tarball installed in an empty project and run in two new repositories. One withnodeandgoin a folder:security.ymlcallsvannt-dev/repokeeper/.github/workflows/codeql.yml@v0with the three languages, andcheckthen reports no drift. One withgithub.workflows.source: local: it also gets its owncodeql.yml, read from the package.workflow-testsnow callscodeql.ymlon JavaScript (read from source), Go (built by CodeQL, withgo.modin a folder) and the workflow files, withupload: never. See thecodeqlchecks of this pull request.Not tested
upload: never, so that the fixtures' findings do not become this repository's alerts. The upload is the action's own default behaviour.vannt-dev/repokeeper-demo-go: with both switches asked for,github apply --dry-runanswers that the settings match (GitHub reports bothenabledthere); with push protection asked off, it printschange security.secret_scanning_push_protection: true -> falseanddry run: nothing applied, and the repository still has it on. ThePATCHitself is covered by the tests' fake only; no repository's settings were changed.@v0: the tag holdscodeql.ymlonly after the next release.