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

Scorecard Integration #1294

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

Conversation

404-geek
Copy link
Collaborator

@404-geek 404-geek commented Jun 26, 2024

ScoreCode Integration

This pull request integrates the ScoreCode Repo into SCIO, enabling the fetching of the latest OSSF Scorecard Data for discovered packages using their vcs_url. The current implementation supports github.com and gitlab.com VCS URLs.

Key Features:

  • Integration with ScoreCode Repo
  • Fetching of OSSF Scorecard Data using vcs_url
  • Support for github.com and gitlab.com VCS URLs

Related Issues:

This feature enhances SCIO's functionality by ensuring that users can retrieve the most up-to-date security scores for packages discovered in their projects, improving overall security assessment and management.

developed functions to check for availability nexB#598

Signed-off-by: 404-geek <[email protected]>
Signed-off-by: 404-geek <[email protected]>
Signed-off-by: 404-geek <[email protected]>
…gration

# Conflicts:
#	scanpipe/models.py
#	scanpipe/tests/test_models.py
@404-geek 404-geek changed the title Scorecard integration Scorecard Integration Jul 26, 2024
Comment on lines 1 to 14
# Generated by Django 5.0.7 on 2024-08-20 16:56

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('scanpipe', '0067_discoveredpackage_notes'),
('scanpipe', '0067_packagescore_scorecardcheck'),
]

operations = [
]
Copy link
Contributor

Choose a reason for hiding this comment

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

The migrations file need to be consolidated.

Migrate your local db to 0066: ./manage.py migrate scanpipe 0066

Delete those migrations files (0067 and 0068) and regenerate a single clean migration file.

Comment on lines +1839 to +1842
selected_steps = models.JSONField(
null=True, blank=True, validators=[validate_none_or_list]
)
selected_steps = models.JSONField(
selected_groups = models.JSONField(
Copy link
Contributor

Choose a reason for hiding this comment

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

Unwanted change.

)

@classmethod
@transaction.atomic()
Copy link
Contributor

Choose a reason for hiding this comment

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

@404-geek Could you provide an example that shows why atomic() is useful here?


@classmethod
@transaction.atomic()
def create_from_data(cls, DiscoveredPackage, scorecard_data, scoring_tool=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why provide the DiscoveredPackage class object as an arg? Isn't it already present in the context/scope?

@classmethod
@transaction.atomic()
def create_from_data(cls, DiscoveredPackage, scorecard_data, scoring_tool=None):
"""Create ScoreCard Object from ScoreCard Object"""
Copy link
Contributor

Choose a reason for hiding this comment

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

"Object" why using upper case here?

Comment on lines 36 to 52
Attributes
----------
download_inputs (bool): Indicates whether inputs should be downloaded.
is_addon (bool): Indicates whether this pipeline is an add-on.

Methods
-------
steps(cls):
Defines the steps for the pipeline.

check_scorecode_service_availability(self):
Checks if the ScoreCode service is configured and available.

lookup_save_packages_scorecode_info(self):
Fetches ScoreCode information for each discovered package in the project
and saves the information to the respective package instances.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is not consistent with existing pipelines.
Also, the Pipeline docstring is used to render documentation in the UI.
The Attributes and Methods are not relevant in that context.

if not scorecard.is_available():
raise Exception("scorecode service is not available.")

def lookup_save_packages_scorecode_info(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

fetch_packages_scorecode_info would be better.

)

else:
raise Exception("No Data Found for the packages")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why mxing upper and lower case in a sentence?

setup.cfg Outdated
@@ -98,6 +98,8 @@ install_requires =
fontawesomefree==6.6.0
# MatchCode-toolkit
matchcode-toolkit==5.1.0
# ScoreCode
ScoreCode[full] @ git+https://github.com/nexB/ScoreCode.git@0ab078f18d83684c3a920095bcec8664d44cf028
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the plan to issue a proper release of ScoreCode?

setup.cfg Outdated
@@ -136,6 +139,7 @@ scancodeio_pipelines =
collect_symbols_tree_sitter = scanpipe.pipelines.collect_symbols_tree_sitter:CollectSymbolsTreeSitter
enrich_with_purldb = scanpipe.pipelines.enrich_with_purldb:EnrichWithPurlDB
find_vulnerabilities = scanpipe.pipelines.find_vulnerabilities:FindVulnerabilities
get_scorecard_info_packages = scanpipe.pipelines.get_scorecard_info_packages:FetchScoreCodeInfo
Copy link
Contributor

Choose a reason for hiding this comment

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

fetch_scorecode_info would be much better and consistent with the pipeline name.

@pombredanne
Copy link
Member

@404-geek can you check the failing tests?

@tdruez
Copy link
Contributor

tdruez commented Oct 29, 2024

Hey @404-geek , what's your latest status on this PR? Any chances we can complete and merge it before it diverges too much from the main branch?

@404-geek
Copy link
Collaborator Author

Hey @404-geek , what's your latest status on this PR? Any chances we can complete and merge it before it diverges too much from the main branch?

Hi @tdruez,

I’m planning to have this PR ready by next week. Most of the requested changes have been addressed; I just need to add a few test cases before pushing the final version.

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.

Store OSSF scorecard data in scancode.io models Enrich an SBOM using OSSF Security Score Card
4 participants