MCPcopy Create free account
hub / github.com/github/gh-aw / parseSecurityTrigger

Function parseSecurityTrigger

pkg/workflow/trigger_parser.go:565–609  ·  view source on GitHub ↗

parseSecurityTrigger parses security-related triggers

(input string)

Source from the content-addressed store, hash-verified

563
564// parseSecurityTrigger parses security-related triggers
565func parseSecurityTrigger(input string) (*TriggerIR, error) {
566 tokens := strings.Fields(input)
567 if len(tokens) < 2 {
568 return nil, nil
569 }
570
571 if tokens[0] == "dependabot" && len(tokens) >= 3 && tokens[1] == "pull" && tokens[2] == "request" {
572 // "dependabot pull request" - filter pull requests by Dependabot author.
573 // Guard against the Dependabot Confused Deputy attack (@dependabot recreate) by
574 // requiring the PR author to also be dependabot[bot], not just the current actor.
575 // Reference: https://labs.boostsecurity.io/articles/weaponizing-dependabot-pwn-request-at-its-finest/
576 return &TriggerIR{
577 Event: "pull_request",
578 Types: []string{"opened", "synchronize", "reopened"},
579 Conditions: []string{"github.actor == 'dependabot[bot]' && github.event.pull_request.user.login == 'dependabot[bot]'"},
580 AdditionalEvents: map[string]any{
581 "workflow_dispatch": nil,
582 },
583 }, nil
584 }
585
586 if tokens[0] == "security" && tokens[1] == "alert" {
587 // "security alert" - code scanning alert
588 return &TriggerIR{
589 Event: "code_scanning_alert",
590 Types: []string{"created", "reopened", "fixed"},
591 AdditionalEvents: map[string]any{
592 "workflow_dispatch": nil,
593 },
594 }, nil
595 }
596
597 if len(tokens) >= 3 && tokens[0] == "code" && tokens[1] == "scanning" && tokens[2] == "alert" {
598 // "code scanning alert" - explicit code scanning alert
599 return &TriggerIR{
600 Event: "code_scanning_alert",
601 Types: []string{"created", "reopened", "fixed"},
602 AdditionalEvents: map[string]any{
603 "workflow_dispatch": nil,
604 },
605 }, nil
606 }
607
608 return nil, nil
609}
610
611// parseExternalTrigger parses external integration triggers
612func parseExternalTrigger(input string) (*TriggerIR, error) {

Callers 1

ParseTriggerShorthandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected