parseSecurityTrigger parses security-related triggers
(input string)
| 563 | |
| 564 | // parseSecurityTrigger parses security-related triggers |
| 565 | func 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 |
| 612 | func parseExternalTrigger(input string) (*TriggerIR, error) { |
no outgoing calls
no test coverage detected