Skip to content

Commit

Permalink
Fix parsing of github action name.
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Mendoza <[email protected]>
  • Loading branch information
jeffmendoza committed Mar 1, 2024
1 parent 609be43 commit c532eed
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions pkg/policies/action/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package action
import (
"context"
"fmt"
"regexp"
"sort"
"strings"

Expand All @@ -34,8 +33,6 @@ import (
const configFile = "actions.yaml"
const polName = "GitHub Actions"

var actionNameVersionRegex = regexp.MustCompile(`^([a-zA-Z0-9_\-.]+\/[a-zA-Z0-9_\-.]+)@([a-zA-Z0-9\-.]+)$`)

const failText = "This policy, specified at the organization level, sets requirements for Action use by repos within the organization. This repo is failing to fully comply with organization policies, as explained below.\n\n```\n%s```\n\nSee the org-level %s policy configuration for details."

const maxWorkflows = 50
Expand Down Expand Up @@ -270,8 +267,8 @@ func (a Action) Check(ctx context.Context, c *github.Client, owner,
// Missing uses in step
continue
}
sm := actionNameVersionRegex.FindStringSubmatch(actionStep.Uses.Value)
if sm == nil {
sm := strings.SplitN(actionStep.Uses.Value, "@", 2)
if len(sm) != 2 {
// Ignore invalid Action
log.Warn().
Str("org", owner).
Expand All @@ -281,8 +278,8 @@ func (a Action) Check(ctx context.Context, c *github.Client, owner,
Msg("Ignoring invalid action")
continue
}
name := sm[1]
version := sm[2]
name := sm[0]
version := sm[1]
actions = append(actions, &actionMetadata{
name: name,
version: version,
Expand Down

0 comments on commit c532eed

Please sign in to comment.