Skip to content

Add config option to specify branches for dangerous workflow #677

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

serb-google
Copy link
Contributor

Add config option to specify branches for dangerous workflow, see #622 (comment)

Tested with and without option in /.allstar/dangerous_workflow.yaml file private branch to confirm this works as expected.

@serb-google
Copy link
Contributor Author

It's not really clear why the linter is failing, I can't replicate this locally with:

 allstar$ ../golangci-lint-1.64.7-linux-amd64/golangci-lint run --timeout 3m
 allstar$ ../golangci-lint-1.64.7-linux-amd64/golangci-lint cache clean

@serb-google
Copy link
Contributor Author

Looks like 24b42f0 resolved the lint error.

@@ -65,6 +65,11 @@ type OrgConfig struct {

// Schedule specifies whether to perform certain actions on specific days.
Schedule *ScheduleConfig `json:"schedule"`

// Comma-seperated branch list to scan for Dangerous Workflows.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: separated. Same for below

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch :)

Signed-off-by: Samuel Erb <[email protected]>
@coheigea
Copy link
Contributor

coheigea commented Apr 7, 2025

What happens if a given branch isn't available in a repo? Will it just skip or throw an error? I'd want to specify "refs/remotes/origin/master", "refs/remotes/origin/main" etc. to catch different default branches in various repos. Or is there a way to always pick the default branch?

@serb-google
Copy link
Contributor Author

What happens if a given branch isn't available in a repo? Will it just skip or throw an error? I'd want to specify "refs/remotes/origin/master", "refs/remotes/origin/main" etc. to catch different default branches in various repos. Or is there a way to always pick the default branch?

Based on https://github.com/serb-google/allstar/blob/config/pkg/policies/workflow/workflow.go#L150 this should throw an error.

I think it should be possible to wire up GetDefaultBranchName() from the scorecard Git client for a magic string like Default ( https://github.com/ossf/scorecard/blob/main/clients/git/client.go#L316 ). I should be able to have that wired up in a few days.

Copy link
Member

@jeffmendoza jeffmendoza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, some naming comments.
Lets preserve the ability to easily only check the default branch, as @coheigea mentioned.

// Comma-separated branch list to scan for Dangerous Workflows.
// Blank/default to scan all branches.
// Must use format "refs/remotes/origin/branch_name".
DangerousWorkflowBranchList string `json:"dangerousWorkflowBranchList"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe you need these config fields. Just the ones you added to the policy-specific config

// Comma-separated branch list to scan for Dangerous Workflows.
// Blank/default to scan all branches.
// Must use format "refs/remotes/origin/branch_name".
DangerousWorkflowBranchList string `json:"dangerousWorkflowBranchList"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this is already a part of the Dangerous Workflow policy config, just name this "BranchList"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants