Repository navigation
[M0.6] Custom Semgrep rules - #12
Merged
Merged
Conversation
samuelmbabhazi
added a commit
that referenced
this pull request
Nov 28, 2026
…epository (closes #214) (#560) Closes #214 (M3.2, shipkeep.yml sync), last of four pull requests. **UI change: waits for the maintainer's validation before merging.** It is stacked on #559, which is stacked on #558: until they merge, their commits show here too. This PR's commits start at "the preview of a change says how it is written". #214's acceptance criterion is "editing replicas in the UI opens a PR with the exact YAML change". It is tested in Chromium on the production build. ## What changed - **Web, `RepositoryConfigEditor`.** The Configuration section of a Git application (`?tab=config§ion=yml`) no longer shows the stored configuration read-only: it edits the repository's file. - The draft starts from the file's text, comments included (`GET …/repository-config`). - The card says which file the application runs: - this file, at a given commit; - an older commit, when the branch has moved on (drift); - or that the file is not a valid configuration for this application. - **Review changes** checks the draft here (YAML, schema, same name), then shows the control plane's preview: the exact lines written, with three around each and `⋯ N unchanged lines` for the rest. - The button names what happens: **Open a pull request**, with "It goes to a branch of its own, in a pull request into main", or **Commit to main**, with "If main is protected, a pull request is opened instead". It sends the document reviewed, with the blob it was reviewed against. - **Once written,** the card says "Pull request #12 opened. Merging it into main deploys the change." or "Committed to main…", with **Open on GitHub**. The draft starts again from the branch's file, so the change is not written twice. - **A file changed in the repository meanwhile** (409 `config_file_changed`) keeps the draft and offers **Load the latest file**; the draft is then reviewed against it. - New strings are translated in `fr.ts`. The read-only notice they replace is removed. - **API:** the preview also answers `writeMode` (the project's `gitWriteMode`), for the button. - **Fix: new projects defaulted to `commit`.** The dashboard's **New project** dialog sent `gitWriteMode: 'commit'` since the design port (#249). That goes against ADR 0031, which makes a change from the interface a pull request unless the project says otherwise. With this editor, every project created there would have committed straight to its branch. It now sends `pull_request`, the database's default; the project settings still change it. The Chromium test is what found this. - **Docs:** SPEC describes the editor and the default. ## How it was tested - **Web unit** (`repository-config-editor.spec.ts`, 7 tests): - the file's text, comments included, as the draft, and the state shown when the application runs it; - drift with both commits, and an invalid file; - a review sending the parsed document and the blob, with the diff shown (skipped run, added lines) and the pull request sentence; - writing that sends the document reviewed, shows "Pull request #12" and its link, then reloads the branch's file; - commit mode's text and button; - a conflict that keeps the draft, loads the latest file and reviews against its new blob; - invalid YAML, a renamed application and an unchanged draft, refused here with no call; - an unreadable file, read again. - **Web unit, overall:** 411/411, including the New project body, now `pull_request`. - **Chromium, production build and CSP** (`github.browser.spec.ts`, new test): - an application created from a repository through the fake GitHub, its file shown with comments; - `scale.replicas: 3` added, then reviewed, with `+ replicas: 3` in the diff; - **Open a pull request** answers 201. GitHub received, on a `shipkeep/config-<12 hex>` branch, **exactly the file with those lines added**, and a pull request into `main` titled "Change the configuration of billing"; - the link points to the pull request, the editor holds the branch's file again, axe passes, and there are no console or CSP errors. - The whole browser suite passes, 31/31. - **API:** unit 1016/1016; integration for the repository config (with `writeMode`), the route matrix, and project resources. Lint, typecheck and format clean. Screenshots (desktop and mobile) are on the validation page linked in the conversation with the maintainer. ## Security considerations - The interface only calls the routes of #558 and #559: the document is validated again there, written over the blob it was reviewed against, with a token for one repository, and audited. - The new-project fix restores the more reversible default, a pull request, for every project created from the dashboard. - The external link to GitHub is the URL the control plane validated (`https://github.com` only), opened with `rel="noopener"`. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * View and edit an application’s repository configuration in the dashboard, with validation and a preview of the exact changes. * Submit reviewed changes as a commit or pull request, based on project settings. Concurrent file changes are detected so you can reload and review before writing. * New projects use pull requests as the default for repository configuration changes. Changes take effect after they’re pushed and applied. * **Documentation** * Added guidance for repository configuration editing, previews, write options, and request limits. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: samuel mbabhazi <[email protected]>
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.
Task
[M0.6] Custom Semgrep rules. Closes #6
What changed
.semgrep/rules/shipkeep-rules.yml, tests in.semgrep/tests/shipkeep-rules.goand.semgrep/tests/shipkeep-rules.ts. Semgrep's test mode pairs the two directories by file name; everyruleid:line must be flagged by the named rule and everyok:line must stay silent. 8 of 8 rules pass.go-no-shell-interpreter: any shell as the program, under any path (sh,bash,dash,ash,zsh,ksh,fish,busybox,cmd,powershell,pwsh), via a metavariable regex instead of a fixed list.go-exec-non-literal-binary(unchanged): program must be a string literal.go-exec-dash-c(new): a-cargument to any program.go-no-raw-process-spawn(new):syscall.Exec,syscall.ForkExec,syscall.StartProcess,os.StartProcess.go-no-privileged-container(new): DockerHostConfigwithPrivileged: trueor host PID, IPC, network or user namespaces (THREAT_MODEL E1), ready for M1.4.ts-no-child-process: now alsozx,cross-spawn,node-pty,require()and dynamicimport()forms.ts-no-prisma-unsafe-raw(unchanged).ts-no-dynamic-code(new):eval,new Function,Function(), string arguments tosetTimeoutandsetInterval..semgrep/rules; the rule-test step always runs.pnpm semgrep:testandpnpm semgrep:scanfor local use (Semgrep installed separately)..semgrep/testsexcluded from Prettier so annotations stay put.Why
Acceptance of M0.6: the security workflow fails on the bad samples and passes on the codebase. Rules without tests silently stop matching when patterns drift.
How it was tested
semgrep --test --config .semgrep/rules .semgrep/tests: 8/8 passed (Semgrep 1.183.0 locally, same version pinned in CI).semgrep scan --config .semgrep/rules --exclude .semgrep/tests --erroron the repository: no findings.actionlint,prettier --check,pnpm nx run-many -t lint: clean.Security considerations
Static guards only. Note that
semgrep --testwith a single rule file and a test directory crashes in Semgrep 1.183.0 (IndexError in path pairing); the rules/tests directory layout avoids it.Checklist
docs/PLAN.mdare met and the task is tickedbuf lintpass