-
-
Notifications
You must be signed in to change notification settings - Fork 127
Scorecard Integration #1294
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
Closed
Closed
Scorecard Integration #1294
Changes from all commits
Commits
Show all changes
76 commits
Select commit
Hold shift + click to select a range
173db43
Add ScoreCard config into settings.py
404-geek 272b99c
code style fix nexB#598
404-geek 944cee2
Merge branch 'refs/heads/ossf_api_template' into scorecard_integration
404-geek bc445c1
settings.py code style fix nexB#598
404-geek f241b3b
mixin import and models declaration nexB#1283
404-geek 605a5cf
transforming scorecard data into object for saving nexB#1283
404-geek 3833dca
added test cases for saving scorecard data into models and modified s…
404-geek 37380c8
Merge branch 'main' into feat-models_integration
404-geek 5502b5f
added score checks mixin to models nexB#1283
404-geek 2aeb2a4
Merge branch 'nexB:main' into feat-models_integration
404-geek 103fca0
empty details in score response handled nexB#1283
404-geek 952e6a6
changed class names to camel case for models and modified the tests n…
404-geek 3ba3db5
code formatted nexB#1283
404-geek 2f2b846
code formatted nexB#1283
404-geek 39a056d
code formatted nexB#1283
404-geek e5f3e7a
docstrings formatted nexB#1283
404-geek c2f5c4d
created basic fetch and availability functions for scorecode pipeline…
404-geek 6ee5b07
Merge branch 'nexB:main' into scorecard_integration
404-geek 760afc2
Merge remote-tracking branch 'origin/scorecard_integration' into scor…
404-geek 0dbc92f
modified doc strings and models and imported ScoreCode package in set…
404-geek d652f42
setup.cfg nexB#1283
404-geek aa154c0
Merge branch 'nexB:main' into scorecard_integration
404-geek 37ad73a
Merge branch 'refs/heads/feat-models_integration' into scorecard_inte…
404-geek 563991b
reinstated deleted code during rebase nexB#1283
404-geek 4632dfc
code formatting nexB#1283
404-geek 923c834
database migrations for scorecard nexB#1283
404-geek 94bfcd0
updated the scanpipe only fields nexB#1283
404-geek d129f73
changed scorecode commit hash for latest pull nexB#1283
404-geek 24c7be0
Merge branch 'nexB:main' into scorecard_integration
404-geek 259f004
update pipeline code and changed scorecode hash commit nexB#1283
404-geek ccd75ae
changed imports structure nexB#1283
404-geek 9d80ef1
Merge branch 'nexB:main' into scorecard_integration
404-geek 29da290
modified lookup and save logic nexB#1283
404-geek 9d72734
merged migrations due to conflicts nexB#1283
404-geek 301122e
updated migrations nexB#1283
404-geek 5812d97
updated doc string for get_scorecard_info_packages.py nexB#1283
404-geek df50416
Added scorecard pipeline to SCIO with intergration test nexB#1283
404-geek 88a43dc
Merge branch 'main' into scorecard_integration
404-geek fc4945e
moved the data to be regenerated if reqiured nexB#1283
404-geek c00b3b3
updated urls for testing nexB#1283
404-geek b97ff7a
added merged migration file nexB#1283
404-geek 496945b
Changed docstring and renamed functions according to suggestions nexB…
404-geek f86d5bb
class name changes in steps of pipeline nexB#1283
404-geek 36e955a
pipeline name updated nexB#1283
404-geek 90c113a
Merge branch 'aboutcode-org:main' into scorecard_integration
404-geek 43886a3
update pipeline code and steps nexB#1283
404-geek 7c134c7
Merge branch 'main' into scorecard_integration
404-geek 3d4d6ea
update pipeline steps to work with scorecode 0.0.2 release nexB#1283
404-geek f4ed4b5
Merge remote-tracking branch 'origin/scorecard_integration' into scor…
404-geek b9229a5
update migration nexB#1283
404-geek f80f111
Merge branch 'aboutcode-org:main' into scorecard_integration
404-geek ee2ea14
update migration nexB#1283
404-geek bd5b9b3
rename pipeline name with data parsing function nexB#1283
404-geek 2b4629e
code valid nexB#1283
404-geek 99ee48d
update setup.cfg nexB#1283
404-geek 80153f8
optimize code while saving score checks nexB#1283
404-geek 77efae0
Merge branch 'aboutcode-org:main' into scorecard_integration
404-geek 113a557
update test cases and regen scorecard data logic nexB#1283
404-geek 64e17fe
update migration file nexB#1283
404-geek 027fe2d
remove unwanted change nexB#1283
404-geek 7f43f9e
Merge branch 'main' into scorecard_integration
404-geek 89d2636
Merge branch 'aboutcode-org:main' into scorecard_integration
404-geek f6f19a7
unit tests for scorecard model functions and minor fixes nexB#1283
404-geek e2eaadf
Merge branch 'aboutcode-org:main' into scorecard_integration
404-geek 3baeac3
updated built-in-pipelines.rst with `ScoreCode` pipeline
404-geek 601201b
Merge remote-tracking branch 'origin/scorecard_integration' into scor…
404-geek c6b9832
fix path bugs
404-geek 8679ddc
change migration file and update `ScoreCode` version
404-geek 8e7fd43
Merge branch 'main' into scorecard_integration
404-geek c6a8ac5
cosmetic changes to pipeline
404-geek 7cd0706
Resolved merge conflict with upstream
404-geek e8275b4
Refactor Code
404-geek b8e6090
Refactor Code
404-geek cda5531
Migration Script
404-geek 5dfb513
Update Migration and redundant check of scores
404-geek dd7d1b1
valid check
404-geek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
64 changes: 64 additions & 0 deletions
64
scanpipe/migrations/0074_add_discovered_package_score_and_scorecard_check_models.py
This file contains hidden or 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,64 @@ | ||
| # Generated by Django 5.1.11 on 2025-07-17 05:29 | ||
|
|
||
| import django.db.models.deletion | ||
| import uuid | ||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('scanpipe', '0073_add_sha1_git_checksum'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.CreateModel( | ||
| name='DiscoveredPackageScore', | ||
| fields=[ | ||
| ('scoring_tool', models.CharField(blank=True, choices=[('ossf-scorecard', 'Ossf'), ('others', 'Others')], help_text='Defines the source of a score or any other scoring metricsFor example: ossf-scorecard for scorecard data', max_length=100)), | ||
| ('scoring_tool_version', models.CharField(blank=True, help_text='Defines the version of the scoring tool used for scanning thepackageFor Eg : 4.6 current version of OSSF - scorecard', max_length=50)), | ||
| ('score', models.CharField(blank=True, help_text='Score of the package which is scanned', max_length=50)), | ||
| ('scoring_tool_documentation_url', models.CharField(blank=True, help_text='Documentation URL of the scoring tool used', max_length=100)), | ||
| ('score_date', models.DateTimeField(blank=True, editable=False, help_text='Date when the scoring was calculated on the package', null=True)), | ||
| ('uuid', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False, verbose_name='UUID')), | ||
| ('discovered_package', models.ForeignKey(editable=False, help_text='The package for which the score is given', on_delete=django.db.models.deletion.CASCADE, related_name='scores', to='scanpipe.discoveredpackage')), | ||
| ], | ||
| options={ | ||
| 'verbose_name': 'discovered package score', | ||
| 'verbose_name_plural': 'discovered package scores', | ||
| 'ordering': ['-score'], | ||
| }, | ||
| ), | ||
| migrations.CreateModel( | ||
| name='ScorecardCheck', | ||
| fields=[ | ||
| ('check_name', models.CharField(blank=True, help_text='Defines the name of check corresponding to the OSSF scoreFor example: Code-Review or CII-Best-PracticesThese are the some of the checks which are performed on a scanned package', max_length=100)), | ||
| ('check_score', models.CharField(blank=True, help_text='Defines the score of the check for the package scannedFor Eg : 9 is a score given for Code-Review', max_length=50)), | ||
| ('reason', models.CharField(blank=True, help_text='Gives a reason why a score was given for a specific checkFor eg, : Found 9/10 approved changesets -- score normalized to 9', max_length=300)), | ||
| ('details', models.JSONField(blank=True, default=list, help_text='A list of details/errors regarding the score')), | ||
| ('uuid', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False, verbose_name='UUID')), | ||
| ('package_score', models.ForeignKey(editable=False, help_text='The checks for which the score is given', on_delete=django.db.models.deletion.CASCADE, related_name='checks', to='scanpipe.discoveredpackagescore')), | ||
| ], | ||
| options={ | ||
| 'verbose_name': 'scorecard check', | ||
| 'verbose_name_plural': 'scorecard checks', | ||
| 'ordering': ['-check_score'], | ||
| }, | ||
| ), | ||
| migrations.AddIndex( | ||
| model_name='discoveredpackagescore', | ||
| index=models.Index(fields=['score'], name='scanpipe_di_score_078964_idx'), | ||
| ), | ||
| migrations.AddIndex( | ||
| model_name='discoveredpackagescore', | ||
| index=models.Index(fields=['scoring_tool_version'], name='scanpipe_di_scoring_7fa482_idx'), | ||
| ), | ||
| migrations.AddIndex( | ||
| model_name='scorecardcheck', | ||
| index=models.Index(fields=['check_score'], name='scanpipe_sc_check_s_e189f7_idx'), | ||
| ), | ||
| migrations.AddIndex( | ||
| model_name='scorecardcheck', | ||
| index=models.Index(fields=['check_name'], name='scanpipe_sc_check_n_1df2b1_idx'), | ||
| ), | ||
| ] |
This file contains hidden or 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 hidden or 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,71 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # http://nexb.com and https://github.com/nexB/scancode.io | ||
| # The ScanCode.io software is licensed under the Apache License version 2.0. | ||
| # Data generated with ScanCode.io is provided as-is without warranties. | ||
| # ScanCode is a trademark of nexB Inc. | ||
| # | ||
| # You may not use this software except in compliance with the License. | ||
| # You may obtain a copy of the License at: http://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. | ||
| # | ||
| # Data Generated with ScanCode.io is provided on an "AS IS" BASIS, WITHOUT WARRANTIES | ||
| # OR CONDITIONS OF ANY KIND, either express or implied. No content created from | ||
| # ScanCode.io should be considered or used as legal advice. Consult an Attorney | ||
| # for any legal advice. | ||
| # | ||
| # ScanCode.io is a free software code scanning tool from nexB Inc. and others. | ||
| # Visit https://github.com/nexB/scancode.io for support and download. | ||
|
|
||
|
|
||
| from scorecode import ossf_scorecard | ||
|
|
||
| from scanpipe.models import DiscoveredPackageScore | ||
| from scanpipe.pipelines import Pipeline | ||
|
|
||
|
|
||
| class FetchScoreCodeInfo(Pipeline): | ||
| """ | ||
| Fetch ScoreCode information for packages. | ||
|
|
||
| This pipeline retrieves ScoreCode data for each package in the project | ||
| and stores it in the corresponding package instances. | ||
tdruez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ScoreCode data refers to metadata retrieved from the OpenSSF Scorecard tool, | ||
| which evaluates open source packages based on security and quality checks. | ||
| This data includes an overall score, individual check results (such as use | ||
| of branch protection, fuzzing, dependency updates, etc.), the version of the | ||
| scoring tool used, and the date of evaluation | ||
| """ | ||
|
|
||
| download_inputs = False | ||
| is_addon = True | ||
|
|
||
| @classmethod | ||
| def steps(cls): | ||
| return ( | ||
| cls.check_scoreCode_service_availability, | ||
| cls.fetch_packages_scoreCode_info, | ||
| ) | ||
|
|
||
| def check_scoreCode_service_availability(self): | ||
| """Check if the ScoreCode service is configured and available.""" | ||
| if not ossf_scorecard.is_available(): | ||
| raise Exception("ScoreCode service is not available.") | ||
|
|
||
| def fetch_packages_scoreCode_info(self): | ||
| """Fetch ScoreCode information for each of the project's discovered packages.""" | ||
| for package in self.project.discoveredpackages.all(): | ||
| scorecard_data = ossf_scorecard.fetch_scorecard_info(package=package) | ||
|
|
||
| if scorecard_data: | ||
| DiscoveredPackageScore.create_from_package_and_scorecard( | ||
| scorecard_data=scorecard_data, | ||
| package=package, | ||
| ) | ||
|
|
||
| else: | ||
| pass | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.