Skip to content

Commit

Permalink
#1350 - Update link references in scanpipe
Browse files Browse the repository at this point in the history
# Visit https://github.com/nexB/scancode.io for support and download.
  • Loading branch information
chinyeungli committed Aug 14, 2024
1 parent 9ef3fee commit ab1c989
Show file tree
Hide file tree
Showing 76 changed files with 268 additions and 211 deletions.
4 changes: 2 additions & 2 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SPDX-License-Identifier: Apache-2.0

http://nexb.com and https://github.com/nexB/scancode.io
http://nexb.com and https://github.com/aboutcode-org/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.
Expand All @@ -18,4 +18,4 @@ 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.
Visit https://github.com/aboutcode-org/scancode.io for support and download.
4 changes: 2 additions & 2 deletions scanpipe/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
#
# http://nexb.com and https://github.com/nexB/scancode.io
# http://nexb.com and https://github.com/aboutcode-org/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.
Expand All @@ -18,7 +18,7 @@
# 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.
# Visit https://github.com/aboutcode-org/scancode.io for support and download.


def humanize_time(seconds):
Expand Down
13 changes: 8 additions & 5 deletions scanpipe/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
#
# http://nexb.com and https://github.com/nexB/scancode.io
# http://nexb.com and https://github.com/aboutcode-org/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.
Expand All @@ -18,7 +18,7 @@
# 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.
# Visit https://github.com/aboutcode-org/scancode.io for support and download.

from django.contrib import admin
from django.urls import reverse
Expand Down Expand Up @@ -55,9 +55,11 @@ class ProjectAdmin(ScanPipeBaseAdmin):
ordering = ["-created_date"]
fieldsets = [
("", {"fields": ("name", "slug", "notes", "extra_data", "settings", "uuid")}),
("Links", {"fields": ("packages_link", "dependencies_link", "resources_link")}),
("Links", {"fields": ("packages_link",
"dependencies_link", "resources_link")}),
]
readonly_fields = ["packages_link", "dependencies_link", "resources_link", "uuid"]
readonly_fields = ["packages_link",
"dependencies_link", "resources_link", "uuid"]

def get_queryset(self, request):
return (
Expand Down Expand Up @@ -116,7 +118,8 @@ class CodebaseResourceAdmin(ScanPipeBaseAdmin):
search_fields = [
"path",
]
list_filter = ["project", "type", "programming_language", "compliance_alert"]
list_filter = ["project", "type",
"programming_language", "compliance_alert"]
ordering = ["project", "path"]


Expand Down
4 changes: 2 additions & 2 deletions scanpipe/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
#
# http://nexb.com and https://github.com/nexB/scancode.io
# http://nexb.com and https://github.com/aboutcode-org/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.
Expand All @@ -18,7 +18,7 @@
# 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.
# Visit https://github.com/aboutcode-org/scancode.io for support and download.


class ExcludeFromListViewMixin:
Expand Down
4 changes: 2 additions & 2 deletions scanpipe/api/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
#
# http://nexb.com and https://github.com/nexB/scancode.io
# http://nexb.com and https://github.com/aboutcode-org/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.
Expand All @@ -18,7 +18,7 @@
# 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.
# Visit https://github.com/aboutcode-org/scancode.io for support and download.

from django.apps import apps

Expand Down
4 changes: 2 additions & 2 deletions scanpipe/api/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
#
# http://nexb.com and https://github.com/nexB/scancode.io
# http://nexb.com and https://github.com/aboutcode-org/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.
Expand All @@ -18,7 +18,7 @@
# 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.
# Visit https://github.com/aboutcode-org/scancode.io for support and download.

import json

Expand Down
19 changes: 12 additions & 7 deletions scanpipe/apps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
#
# http://nexb.com and https://github.com/nexB/scancode.io
# http://nexb.com and https://github.com/aboutcode-org/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.
Expand All @@ -18,7 +18,7 @@
# 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.
# Visit https://github.com/aboutcode-org/scancode.io for support and download.

import inspect
import logging
Expand Down Expand Up @@ -89,10 +89,12 @@ def load_pipelines(self):
pipelines Python files found at `SCANCODEIO_PIPELINES_DIRS` locations.
"""
entry_points = importlib_metadata.entry_points()
pipeline_entry_points = set(entry_points.select(group="scancodeio_pipelines"))
pipeline_entry_points = set(
entry_points.select(group="scancodeio_pipelines"))

for entry_point in sorted(pipeline_entry_points):
self.register_pipeline(name=entry_point.name, cls=entry_point.load())
self.register_pipeline(name=entry_point.name,
cls=entry_point.load())

pipelines_dirs = getattr(settings, "SCANCODEIO_PIPELINES_DIRS", [])
logger.debug(f"Load user provided pipelines from {pipelines_dirs}")
Expand Down Expand Up @@ -222,13 +224,15 @@ def set_policies(self):
include the proper content, we want to raise an exception while the app
is loading to warn system admins about the issue.
"""
policies_file_location = getattr(settings, "SCANCODEIO_POLICIES_FILE", None)
policies_file_location = getattr(
settings, "SCANCODEIO_POLICIES_FILE", None)

if policies_file_location:
policies_file = Path(policies_file_location).expanduser()

if policies_file.exists():
logger.debug(style.SUCCESS(f"Load policies from {policies_file}"))
logger.debug(style.SUCCESS(
f"Load policies from {policies_file}"))
policies = saneyaml.load(policies_file.read_text())
license_policies = policies.get("license_policies", [])
self.license_policies_index = self.get_policies_index(
Expand All @@ -251,7 +255,8 @@ def policies_enabled(self):

def sync_runs_and_jobs(self):
"""Synchronize ``QUEUED`` and ``RUNNING`` Run with their related Jobs."""
logger.info("Synchronizing QUEUED and RUNNING Run with their related Jobs...")
logger.info(
"Synchronizing QUEUED and RUNNING Run with their related Jobs...")

run_model = self.get_model("Run")
queued_or_running = run_model.objects.queued_or_running()
Expand Down
34 changes: 22 additions & 12 deletions scanpipe/filters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
#
# http://nexb.com and https://github.com/nexB/scancode.io
# http://nexb.com and https://github.com/aboutcode-org/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.
Expand All @@ -18,7 +18,7 @@
# 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.
# Visit https://github.com/aboutcode-org/scancode.io for support and download.

import shlex

Expand Down Expand Up @@ -91,7 +91,8 @@ def field(self):

# Retrieve distinct values for the specified field.
field_values = (
qs.order_by(field_name).values_list(field_name, flat=True).distinct()
qs.order_by(field_name).values_list(
field_name, flat=True).distinct()
)
value_choices = [
(value, value) for value in field_values if value not in EMPTY_VALUES
Expand Down Expand Up @@ -247,9 +248,11 @@ def filter_queryset(self, queryset):
for name, value in self.form.cleaned_data.items():
field_name = self.filters[name].field_name
if value == self.empty_value:
queryset = queryset.filter(**{f"{field_name}__in": EMPTY_VALUES})
queryset = queryset.filter(
**{f"{field_name}__in": EMPTY_VALUES})
elif value == self.any_value:
queryset = queryset.filter(~Q(**{f"{field_name}__in": EMPTY_VALUES}))
queryset = queryset.filter(
~Q(**{f"{field_name}__in": EMPTY_VALUES}))
elif value == self.other_value and hasattr(queryset, "less_common"):
return queryset.less_common(name)
else:
Expand Down Expand Up @@ -299,7 +302,8 @@ def parse_query_string_to_lookups(query_string, default_lookup_expr, default_fie
search_value = term
field_name = default_field

lookups &= Q(**{f"{field_name}__{lookup_expr}": search_value}, _negated=negated)
lookups &= Q(
**{f"{field_name}__{lookup_expr}": search_value}, _negated=negated)

return lookups

Expand Down Expand Up @@ -416,7 +420,8 @@ def __init__(self, data=None, *args, **kwargs):
archived_count = Project.objects.filter(is_archived=True).count()
self.filters["is_archived"].extra["widget"] = BulmaLinkWidget(
choices=[
("", f'<i class="fa-solid fa-seedling"></i> {active_count} Active'),
("",
f'<i class="fa-solid fa-seedling"></i> {active_count} Active'),
(
"true",
f'<i class="fa-solid fa-dice-d6"></i> {archived_count} Archived',
Expand Down Expand Up @@ -680,14 +685,16 @@ class PackageFilterSet(FilterSetUtilsMixin, django_filters.FilterSet):
"tag",
"resources_count",
],
grouped_fields={"package_url": ["type", "namespace", "name", "version"]},
grouped_fields={"package_url": [
"type", "namespace", "name", "version"]},
)
purl = PackageURLFilter(label="Package URL")
is_vulnerable = IsVulnerable(field_name="affected_by_vulnerabilities")
compliance_alert = django_filters.ChoiceFilter(
choices=[(EMPTY_VAR, "None")] + CodebaseResource.Compliance.choices,
)
copyright = django_filters.filters.CharFilter(widget=HasValueDropdownWidget)
copyright = django_filters.filters.CharFilter(
widget=HasValueDropdownWidget)
declared_license_expression = django_filters.filters.CharFilter(
widget=HasValueDropdownWidget
)
Expand Down Expand Up @@ -767,7 +774,8 @@ class DependencyFilterSet(FilterSetUtilsMixin, django_filters.FilterSet):
"datafile_resource",
"datasource_id",
],
grouped_fields={"package_url": ["type", "namespace", "name", "version"]},
grouped_fields={"package_url": [
"type", "namespace", "name", "version"]},
)
purl = PackageURLFilter(label="Package URL")
type = ModelFieldValuesFilter()
Expand Down Expand Up @@ -843,7 +851,8 @@ def get_status_choices(qs, include_any=False):
status_values = (
qs.order_by("status").values_list("status", flat=True).distinct()
)
value_choices = [(status, status) for status in status_values if status]
value_choices = [(status, status)
for status in status_values if status]
return default_choices + value_choices


Expand Down Expand Up @@ -885,4 +894,5 @@ def __init__(self, *args, **kwargs):
if project:
qs = CodebaseResource.objects.filter(project=project)
status_filter = self.filters["status"]
status_filter.extra["choices"] = status_filter.get_status_choices(qs)
status_filter.extra["choices"] = status_filter.get_status_choices(
qs)
28 changes: 18 additions & 10 deletions scanpipe/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
#
# http://nexb.com and https://github.com/nexB/scancode.io
# http://nexb.com and https://github.com/aboutcode-org/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.
Expand All @@ -18,7 +18,7 @@
# 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.
# Visit https://github.com/aboutcode-org/scancode.io for support and download.

from django import forms
from django.apps import apps
Expand All @@ -42,7 +42,8 @@ class MultipleFileInput(forms.ClearableFileInput):

class MultipleFileField(forms.FileField):
def __init__(self, *args, **kwargs):
kwargs.setdefault("widget", MultipleFileInput(attrs={"class": "file-input"}))
kwargs.setdefault("widget", MultipleFileInput(
attrs={"class": "file-input"}))
super().__init__(*args, **kwargs)

def clean(self, data, initial=None):
Expand Down Expand Up @@ -170,7 +171,8 @@ def __init__(self, *args, **kwargs):
name_field.help_text = "The unique name of your project."

# Do not include "add-on" pipelines in the context of the create Project form
pipeline_choices = scanpipe_app.get_pipeline_choices(include_addon=False)
pipeline_choices = scanpipe_app.get_pipeline_choices(
include_addon=False)
self.fields["pipeline"].choices = pipeline_choices

def clean_name(self):
Expand Down Expand Up @@ -205,7 +207,8 @@ class AddLabelsForm(forms.Form):
labels = TagField(
label="Add labels to this project:",
widget=TagWidget(
attrs={"class": "input", "placeholder": "Comma-separated list of labels"}
attrs={"class": "input",
"placeholder": "Comma-separated list of labels"}
),
)

Expand Down Expand Up @@ -397,7 +400,8 @@ class ProjectSettingsForm(forms.ModelForm):
ignored_dependency_scopes = KeyValueListField(
label="Ignored dependency scopes",
required=False,
help_text=convert_markdown_to_html(ignored_dependency_scopes_help.strip()),
help_text=convert_markdown_to_html(
ignored_dependency_scopes_help.strip()),
widget=forms.Textarea(
attrs={
"class": "textarea is-dynamic",
Expand All @@ -411,7 +415,8 @@ class ProjectSettingsForm(forms.ModelForm):
ignored_vulnerabilities = ListTextarea(
label="Ignored vulnerabilities",
required=False,
help_text=convert_markdown_to_html(ignored_vulnerabilities_help.strip()),
help_text=convert_markdown_to_html(
ignored_vulnerabilities_help.strip()),
widget=forms.Textarea(
attrs={
"class": "textarea is-dynamic",
Expand All @@ -432,7 +437,8 @@ class ProjectSettingsForm(forms.ModelForm):
"\nFeel free to modify its content according to your preferences and paste "
"the entire HTML code into this field."
),
widget=forms.Textarea(attrs={"class": "textarea is-dynamic", "rows": 3}),
widget=forms.Textarea(
attrs={"class": "textarea is-dynamic", "rows": 3}),
)
product_name = forms.CharField(
label="Product name",
Expand Down Expand Up @@ -489,7 +495,8 @@ def update_project_settings(self, project):


class ProjectCloneForm(forms.Form):
clone_name = forms.CharField(widget=forms.TextInput(attrs={"class": "input"}))
clone_name = forms.CharField(
widget=forms.TextInput(attrs={"class": "input"}))
copy_inputs = forms.BooleanField(
initial=True,
required=False,
Expand Down Expand Up @@ -547,7 +554,8 @@ class Meta:

def __init__(self, *args, **kwargs):
if not kwargs.get("instance"):
raise ValueError("An Run object is required to instantiate this form.")
raise ValueError(
"An Run object is required to instantiate this form.")

super().__init__(*args, **kwargs)
pipeline_class = self.instance.pipeline_class
Expand Down
Loading

0 comments on commit ab1c989

Please sign in to comment.