fix(security): gitea_security_audit and gitea_branch_protection_get default to "main" instead of the repo default branch #20
Labels
No labels
area/dsh
area/forgejo
experiment
priority/later
priority/next
priority/now
type/bug
type/task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
dsh-plugins/dsh-gitea#20
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Symptom
The security tools audit a branch literally named
mainwhen nobranchis passed. This repo's default branch ismaster(renamed on 2026-10-23), so the audit inspects a deleted branch and reports findings for it.Repro
Observed vs expected
@mainand scores a branch that does not exist.master) and label the report with it. If an explicit branch is missing, say so instead of auditing it silently.Root cause
lib/branch-protection.jshard-codes the fallback in three places:lib/tool-defs/repos.jsdocumentsdefaults to mainfor both tools.Proposed fix
Resolve the default branch from the repo API (
client.getRepo(owner, repo).default_branch) whenargs.branchis absent; fall back tomainonly if that lookup fails. Update the tool descriptions and add tests with a repo whose default branch ismaster.Acceptance:
gitea_security_auditwithoutbranchreports@masteron this repo; an explicit nonexistent branch produces a clear "branch not found" error rather than a protection finding.Duplicate check
Searched issues for
security,branch,protection(state all) — #2–#18 cover formatters/wiki/labels, none covers branch defaults.Layer
dsh-gitea plugin/tool.
Fixed in
281eade(PR #40).Added
resolveTargetBranch()used bybranch_protection_get,branch_protection_setandsecurity_audit: an explicit branch is verified againstlistBranches(missing →branch not found: …); otherwisegetRepo().default_branchis used, withmainonly as a last-resort fallback. Tool descriptions updated.Live:
gitea_security_auditwithout a branch →Security Audit for dsh-plugins/dsh-gitea@master; explicitno-such-branch→branch not found: no-such-branch.Tests:
test/qa-defaults.test.mjs.