-
Notifications
You must be signed in to change notification settings - Fork 0
fix: auto-create missing required labels during compliance audit #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,16 @@ ISSUES_FILE="$REPORT_DIR/issues.json" | |
|
|
||
| REQUIRED_WORKFLOWS=(ci.yml codeql.yml sonarcloud.yml claude.yml dependabot-automerge.yml dependency-audit.yml agent-shield.yml) | ||
|
|
||
| REQUIRED_LABELS=(security dependencies scorecard bug enhancement documentation in-progress) | ||
| # name:hex-color:description (color without leading #) | ||
| REQUIRED_LABEL_SPECS=( | ||
| "security:d93f0b:Security-related PRs and issues" | ||
| "dependencies:0075ca:Dependency update PRs" | ||
| "scorecard:d93f0b:OpenSSF Scorecard findings (auto-created)" | ||
| "bug:d73a4a:Bug reports" | ||
| "enhancement:a2eeef:Feature requests" | ||
| "documentation:0075ca:Documentation changes" | ||
| "in-progress:fbca04:An agent is actively working this issue" | ||
| ) | ||
|
|
||
| REQUIRED_SETTINGS_BOOL=( | ||
| "allow_auto_merge:true:warning:Allow auto-merge must be enabled for Dependabot workflow" | ||
|
|
@@ -301,11 +310,28 @@ check_labels() { | |
| local existing_labels | ||
| existing_labels=$(gh_api "repos/$ORG/$repo/labels" --jq '.[].name' --paginate 2>/dev/null || echo "") | ||
|
||
|
|
||
| for label in "${REQUIRED_LABELS[@]}"; do | ||
| for spec in "${REQUIRED_LABEL_SPECS[@]}"; do | ||
| IFS=':' read -r label color description <<< "$spec" | ||
|
Comment on lines
+313
to
+314
|
||
| if ! echo "$existing_labels" | grep -qx "$label"; then | ||
|
||
| add_finding "$repo" "labels" "missing-label-$label" "warning" \ | ||
| "Required label \`$label\` is missing" \ | ||
| "standards/github-settings.md#labels--standard-set" | ||
| if [ "$DRY_RUN" = "true" ]; then | ||
| add_finding "$repo" "labels" "missing-label-$label" "warning" \ | ||
| "Required label \`$label\` is missing" \ | ||
| "standards/github-settings.md#labels--standard-set" | ||
| else | ||
| info "Auto-creating missing label '$label' on $repo" | ||
| if gh label create "$label" \ | ||
| --repo "$ORG/$repo" \ | ||
| --color "$color" \ | ||
| --description "$description" \ | ||
| --force 2>/dev/null; then | ||
|
Comment on lines
+322
to
+326
|
||
| info "Label '$label' created successfully on $repo" | ||
| else | ||
| warn "Failed to create label '$label' on $repo — filing finding for manual remediation" | ||
| add_finding "$repo" "labels" "missing-label-$label" "warning" \ | ||
| "Required label \`$label\` is missing and could not be auto-created" \ | ||
| "standards/github-settings.md#labels--standard-set" | ||
| fi | ||
| fi | ||
| fi | ||
| done | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unify required-label metadata to a single source of truth.
REQUIRED_LABEL_SPECSis standards-aligned, butensure_required_labels()still hardcodes a second label list with different metadata (notablyscorecarddescription). Sinceensure_required_labels()runs with--force, it can overwrite the new spec and cause drift.Proposed refactor
# Create all required labels (idempotent — uses --force to update if present) ensure_required_labels() { local repo="$1" - # Format: "name|color|description" (pipe-delimited to avoid colon conflicts) - local label_configs=( - "security|d93f0b|Security-related PRs and issues" - "dependencies|0075ca|Dependency update PRs" - "scorecard|d93f0b|OpenSSF Scorecard findings" - "bug|d73a4a|Bug reports" - "enhancement|a2eeef|Feature requests" - "documentation|0075ca|Documentation changes" - "in-progress|fbca04|An agent is actively working this issue" - ) - - for config in "${label_configs[@]}"; do - IFS='|' read -r name color description <<< "$config" + for spec in "${REQUIRED_LABEL_SPECS[@]}"; do + IFS=':' read -r name color description <<< "$spec" gh label create "$name" \ --repo "$ORG/$repo" \ --description "$description" \ --color "$color" \ --force 2>/dev/null || true done }🤖 Prompt for AI Agents