Repository navigation
fix: use PUT for repository ruleset updates - #13
Merged
Merged
Conversation
hugo2006alm
requested review from
david-fs-valente and
dinisjcorreia
as code owners
September 9, 2026 00:29
There was a problem hiding this comment.
🟡 Changes recommended
The switch to PUT can unintentionally clear live-only ruleset fields (e.g., bypass_actors) that are not present in the preset payload, changing ruleset behavior during --apply.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adjusts tools/repo_security.py to use the correct HTTP method when updating existing GitHub repository rulesets, aligning the script with the Rulesets REST API behavior and preventing the 404 Not Found seen during --apply.
Changes:
- Switches ruleset updates from
PATCHtoPUTonrepos/{owner}/{repo}/rulesets/{ruleset_id}. - Keeps
PATCHfor CodeQL Default Setup (where it remains the appropriate method). - Clarifies the CLI help description to explicitly mention “repository rulesets”.
File summaries
| File | Description |
|---|---|
| tools/repo_security.py | Uses PUT for ruleset updates and refines CLI description text. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
172
to
176
| if apply: | ||
| api_request( | ||
| token, | ||
| "PATCH", | ||
| "PUT", | ||
| f"/repos/{org}/{repo}/rulesets/{ruleset_id}", |
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.
Resumo
Corrige o método HTTP usado por
tools/repo_security.pyao atualizar rulesets existentes.PATCHporPUTapenas no endpointrepos/{owner}/{repo}/rulesets/{ruleset_id};PATCHno endpoint de CodeQL Default Setup, onde continua a ser o método correto;404 Not Foundobservado ao aplicar presets com--apply.Validação: o endpoint de rulesets foi confirmado manualmente no
template-sei-website, ondePUTatualizou com sucesso os rulesetsmainedev.