-
Notifications
You must be signed in to change notification settings - Fork 500
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Added independent probe for required MFA
Signed-off-by: Eddie Knight <[email protected]>
- Loading branch information
1 parent
1703089
commit 76b2b23
Showing
11 changed files
with
250 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright 2024 OpenSSF Scorecard Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
id: orgRequiresMFA # required | ||
lifecycle: experimental # required | ||
short: A short description of this probe | ||
motivation: > | ||
What is the motivation for this probe? | ||
implementation: > | ||
How does this probe work under-the-hood? | ||
outcome: | ||
- If MFA is found to be required, the probe returns OutcomeTrue | ||
- IF MFA is not found to be required, the probe returns OutcomeFalse | ||
- If the runtime environment does not have authentication for the target project, the probe returns OutcomeNotAvailable | ||
remediation: | ||
onOutcome: False # required | ||
effort: Low # required | ||
text: | ||
- In your project settings, require MFA for all collaborators. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright 2024 OpenSSF Scorecard Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//nolint:stylecheck | ||
package orgRequiresMFA | ||
|
||
import ( | ||
"embed" | ||
"fmt" | ||
|
||
"github.com/ossf/scorecard/v5/checker" | ||
"github.com/ossf/scorecard/v5/finding" | ||
"github.com/ossf/scorecard/v5/internal/probes" | ||
"github.com/ossf/scorecard/v5/probes/internal/utils/uerror" | ||
) | ||
|
||
//go:embed *.yml | ||
var fs embed.FS | ||
|
||
const ( | ||
Probe = "orgRequiresMFA" | ||
) | ||
|
||
func init() { | ||
// Register independently of any checks | ||
probes.MustRegisterIndependent(Probe, Run) | ||
} | ||
|
||
func Run(raw *checker.CheckRequest) (found []finding.Finding, probeName string, err error) { | ||
if raw == nil { | ||
err = fmt.Errorf("raw results is nil: %w", uerror.ErrNil) | ||
return found, Probe, err | ||
} | ||
|
||
mfaRequired, err := raw.RepoClient.GetMFARequired() | ||
if err != nil { | ||
err = fmt.Errorf("getting MFA required: %w", err) | ||
return found, Probe, err | ||
} | ||
|
||
var outcome finding.Outcome | ||
if mfaRequired { | ||
outcome = finding.OutcomeTrue | ||
} else { | ||
outcome = finding.OutcomeFalse | ||
} | ||
|
||
result, err := finding.NewWith( | ||
fs, | ||
Probe, | ||
"Collaborators require MFA", | ||
nil, | ||
outcome, | ||
) | ||
|
||
if err != nil { | ||
err = fmt.Errorf("creating finding: %w", err) | ||
return found, Probe, err | ||
} | ||
|
||
found = append(found, *result) | ||
|
||
return found, Probe, err | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.