-
Notifications
You must be signed in to change notification settings - Fork 498
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] add two remaining license checks as probes
Signed-off-by: AdamKorcz <[email protected]>
- Loading branch information
Showing
11 changed files
with
674 additions
and
10 deletions.
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
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,26 @@ | ||
# Copyright 2023 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: hasApprovedLicenseFile | ||
short: Check that the project has a license file of approved format | ||
motivation: > | ||
A license can give users information about how the source code may or may not be used. The lack of a license will impede any kind of security review or audit and creates a legal risk for potential users. | ||
implementation: > | ||
The implementation checks whether a license file is present and is of an approved format | ||
outcome: | ||
- If a license file is found, the outcome is positive. | ||
remediation: | ||
effort: Low | ||
text: | ||
- Update the license file format in the Github repository. |
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,70 @@ | ||
// Copyright 2023 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 hasApprovedLicenseFile | ||
|
||
import ( | ||
"embed" | ||
"fmt" | ||
|
||
"github.com/ossf/scorecard/v4/checker" | ||
"github.com/ossf/scorecard/v4/finding" | ||
"github.com/ossf/scorecard/v4/probes/internal/utils/uerror" | ||
) | ||
|
||
//go:embed *.yml | ||
var fs embed.FS | ||
|
||
const Probe = "hasApprovedLicenseFile" | ||
|
||
func Run(raw *checker.RawResults) ([]finding.Finding, string, error) { | ||
if raw == nil { | ||
return nil, "", fmt.Errorf("%w: raw", uerror.ErrNil) | ||
} | ||
|
||
if raw.LicenseResults.LicenseFiles == nil || len(raw.LicenseResults.LicenseFiles) == 0 { | ||
f, err := finding.NewWith(fs, Probe, | ||
"project doe not have a license file", nil, | ||
finding.OutcomeNegative) | ||
if err != nil { | ||
return nil, Probe, fmt.Errorf("create finding: %w", err) | ||
} | ||
return []finding.Finding{*f}, Probe, nil | ||
} | ||
|
||
for _, licenseFile := range raw.LicenseResults.LicenseFiles { | ||
if licenseFile.LicenseInformation.Approved { | ||
if licenseFile.LicenseInformation.Approved { | ||
msg := "License file is of approved type" | ||
|
||
f, err := finding.NewWith(fs, Probe, | ||
msg, nil, | ||
finding.OutcomePositive) | ||
if err != nil { | ||
return nil, Probe, fmt.Errorf("create finding: %w", err) | ||
} | ||
return []finding.Finding{*f}, Probe, nil | ||
} | ||
} | ||
} | ||
|
||
f, err := finding.NewWith(fs, Probe, | ||
"project license files has no approved information", nil, | ||
finding.OutcomeNegative) | ||
if err != nil { | ||
return nil, Probe, fmt.Errorf("create finding: %w", err) | ||
} | ||
return []finding.Finding{*f}, Probe, nil | ||
} |
Oops, something went wrong.