Skip to content
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

🌱 Add probes for Branch Protection #3691

Merged
merged 30 commits into from
Dec 27, 2023

Conversation

AdamKorcz
Copy link
Contributor

What kind of change does this PR introduce?

Feature

What is the new behavior (if this is a feature change)?**

This adds 9 probes for the Branch Protection check.

  • Tests for the changes have been added (for bug fixes/features)

Which issue(s) this PR fixes

None

Special notes for your reviewer

The probes are not invoked anywhere by Scorecard; the PR does not change the evaluation. I will do that in a follow-up PR once this has landed.

Does this PR introduce a user-facing change?

NONE


@AdamKorcz AdamKorcz requested a review from a team as a code owner November 21, 2023 23:43
@AdamKorcz AdamKorcz requested review from justaugustus and laurentsimon and removed request for a team November 21, 2023 23:43
Copy link

codecov bot commented Nov 21, 2023

Codecov Report

Merging #3691 (24f9b94) into main (c1a0557) will increase coverage by 2.23%.
The diff coverage is 74.12%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3691      +/-   ##
==========================================
+ Coverage   66.68%   68.91%   +2.23%     
==========================================
  Files         217      227      +10     
  Lines       15061    15347     +286     
==========================================
+ Hits        10043    10577     +534     
+ Misses       4434     4124     -310     
- Partials      584      646      +62     

Copy link

github-actions bot commented Dec 2, 2023

This pull request is stale because it has been open for 10 days with no activity

@github-actions github-actions bot added the Stale label Dec 2, 2023
Copy link
Contributor

@spencerschrock spencerschrock left a comment

Choose a reason for hiding this comment

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

Most of the reviewing time was spent reading the yaml definitions. I think some of these branch protection settings are easier to do than others, so I tried to leave comments on the ones I think are low/medium effort.

There were comments that applied to most of these probes, so I got tired of leaving them. They generally were:

  1. mentioning the branch protection rules in general are only for default/release branches.
  2. the need to mention outcome not available if relevant
  3. some of the remediation is specific, some of it isn't. Need to figure out what @laurentsimon wants in terms of level of detail.

In terms of the implementations, there's a huge amount of code duplication problem. This is mainly targeted at the ones whose existence is just a bool pointer. They can be extracted to some helper to cut down on duplication. Some of these checks have more complicated scenarios, so I realize they won't use the helper.

In terms of testing, I prefer the names reflect the behavior being tested, not describing the test. In general, this had to do with the OutcomeNotAvailable not being reflected in the testname, and the test was doing more than one thing.

probes/blocksDeleteOnBranches/def.yml Outdated Show resolved Hide resolved
probes/blocksDeleteOnBranches/def.yml Outdated Show resolved Hide resolved
probes/blocksDeleteOnBranches/def.yml Outdated Show resolved Hide resolved
probes/blocksDeleteOnBranches/impl.go Outdated Show resolved Hide resolved
probes/blocksDeleteOnBranches/impl_test.go Outdated Show resolved Hide resolved
probes/requiresUpToDateBranches/def.yml Show resolved Hide resolved
probes/requiresUpToDateBranches/impl.go Outdated Show resolved Hide resolved
probes/requiresUpToDateBranches/impl_test.go Outdated Show resolved Hide resolved
probes/runsStatusChecksBeforeMerging/def.yml Outdated Show resolved Hide resolved
probes/runsStatusChecksBeforeMerging/def.yml Outdated Show resolved Hide resolved
@AdamKorcz
Copy link
Contributor Author

In terms of the implementations, there's a huge amount of code duplication problem. This is mainly targeted at the ones whose existence is just a bool pointer. They can be extracted to some helper to cut down on duplication. Some of these checks have more complicated scenarios, so I realize they won't use the helper.

I added this helper here: dd371e3. WDYT?

Signed-off-by: Adam Korczynski <adam@adalogics.com>
Signed-off-by: Adam Korczynski <adam@adalogics.com>
Signed-off-by: Adam Korczynski <adam@adalogics.com>
Signed-off-by: Adam Korczynski <adam@adalogics.com>
Signed-off-by: Adam Korczynski <adam@adalogics.com>
Signed-off-by: Adam Korczynski <adam@adalogics.com>
Signed-off-by: Adam Korczynski <adam@adalogics.com>
…eference

Signed-off-by: Adam Korczynski <adam@adalogics.com>
Copy link
Contributor

@spencerschrock spencerschrock left a comment

Choose a reason for hiding this comment

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

there may be some polish needed, but since it's not hooked up at this point, we'll have to wait until merge and next PR.

Just to be explicit, do you plan on doing the PR required probe in this one? a separate PR? or in the connecting PR?

probes/requiresUpToDateBranches/impl.go Outdated Show resolved Hide resolved
@AdamKorcz
Copy link
Contributor Author

do you plan on doing the PR required probe in this one? a separate PR? or in the connecting PR?

In a separate PR.

Signed-off-by: Adam Korczynski <adam@adalogics.com>
@spencerschrock spencerschrock enabled auto-merge (squash) December 27, 2023 22:24
@spencerschrock spencerschrock merged commit 2e1059b into ossf:main Dec 27, 2023
38 checks passed
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.

None yet

3 participants