Skip to content

fix: use PUT for repository ruleset updates - #13

Merged
hugo2006alm merged 1 commit into
masterfrom
fix/ruleset-update-method
Sep 9, 2026
Merged

hugo2006alm merged 1 commit into
masterfrom
fix/ruleset-update-method

Conversation

@hugo2006alm

Copy link
Copy Markdown
Contributor

Resumo

Corrige o método HTTP usado por tools/repo_security.py ao atualizar rulesets existentes.

  • troca PATCH por PUT apenas no endpoint repos/{owner}/{repo}/rulesets/{ruleset_id};
  • mantém PATCH no endpoint de CodeQL Default Setup, onde continua a ser o método correto;
  • evita o 404 Not Found observado ao aplicar presets com --apply.

Validação: o endpoint de rulesets foi confirmado manualmente no template-sei-website, onde PUT atualizou com sucesso os rulesets main e dev.

Copilot AI lite review requested due to automatic review settings September 9, 2026 00:29
@hugo2006alm
hugo2006alm merged commit 4769296 into master Sep 9, 2026
4 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 PATCH to PUT on repos/{owner}/{repo}/rulesets/{ruleset_id}.
  • Keeps PATCH for 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 thread tools/repo_security.py
Comment on lines 172 to 176
if apply:
api_request(
token,
"PATCH",
"PUT",
f"/repos/{org}/{repo}/rulesets/{ruleset_id}",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants