Skip to content

Commit

Permalink
Refine the code and fix failing tests #1524
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <[email protected]>
  • Loading branch information
tdruez committed Jan 10, 2025
1 parent 727bbba commit cf2d503
Show file tree
Hide file tree
Showing 19 changed files with 2,154 additions and 4,317 deletions.
10 changes: 0 additions & 10 deletions scanpipe/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ def create(self, validated_data):
class CodebaseResourceSerializer(serializers.ModelSerializer):
for_packages = serializers.JSONField()
compliance_alert = serializers.CharField()
project = serializers.CharField(source="project.name")

class Meta:
model = CodebaseResource
Expand Down Expand Up @@ -380,14 +379,12 @@ class Meta:
"emails",
"urls",
"extra_data",
"project",
]


class DiscoveredPackageSerializer(serializers.ModelSerializer):
purl = serializers.CharField(source="package_url")
compliance_alert = serializers.CharField()
project = serializers.CharField(source="project.name")

class Meta:
model = DiscoveredPackage
Expand Down Expand Up @@ -441,7 +438,6 @@ class Meta:
"missing_resources",
"modified_resources",
"affected_by_vulnerabilities",
"project",
]


Expand All @@ -451,7 +447,6 @@ class DiscoveredDependencySerializer(serializers.ModelSerializer):
resolved_to_package_uid = serializers.ReadOnlyField()
datafile_path = serializers.ReadOnlyField()
package_type = serializers.ReadOnlyField(source="type")
project = serializers.CharField(source="project.name")

class Meta:
model = DiscoveredDependency
Expand All @@ -470,14 +465,12 @@ class Meta:
"datasource_id",
"package_type",
"affected_by_vulnerabilities",
"project",
]


class CodebaseRelationSerializer(serializers.ModelSerializer):
from_resource = serializers.ReadOnlyField(source="from_resource.path")
to_resource = serializers.ReadOnlyField(source="to_resource.path")
project = serializers.CharField(source="project.name")

class Meta:
model = CodebaseRelation
Expand All @@ -487,13 +480,11 @@ class Meta:
"map_type",
"score",
"from_resource",
"project",
]


class ProjectMessageSerializer(serializers.ModelSerializer):
traceback = serializers.SerializerMethodField()
project = serializers.CharField(source="project.name")

class Meta:
model = ProjectMessage
Expand All @@ -505,7 +496,6 @@ class Meta:
"details",
"traceback",
"created_date",
"project",
]

def get_traceback(self, project_error):
Expand Down
4 changes: 1 addition & 3 deletions scanpipe/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ def get_queryset(self):
from scanpipe.models import DiscoveredPackage
from scanpipe.models import ProjectMessage
from scanpipe.pipes import flag
from scanpipe.pipes.output import TODO_FIELDS

querysets = {
"discoveredpackage": (
Expand Down Expand Up @@ -324,8 +323,7 @@ def get_queryset(self):
),
"projectmessage": ProjectMessage.objects.all(),
"todos": (
CodebaseResource.objects.files()
.status(flag.REQUIRES_REVIEW)
CodebaseResource.objects.files().status(flag.REQUIRES_REVIEW)
# .only(*TODO_FIELDS)
),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@
"file_references": [],
"missing_resources": [],
"modified_resources": [],
"affected_by_vulnerabilities": [],
"project": "Tool: scancode-toolkit"
"affected_by_vulnerabilities": []
},
{
"purl": "pkg:pypi/[email protected]",
Expand Down Expand Up @@ -271,8 +270,7 @@
"file_references": [],
"missing_resources": [],
"modified_resources": [],
"affected_by_vulnerabilities": [],
"project": "Tool: scancode-toolkit"
"affected_by_vulnerabilities": []
}
],
"dependencies": [
Expand All @@ -290,8 +288,7 @@
"datafile_path": "asgiref-3.3.0-py3-none-any.whl",
"datasource_id": "pypi_wheel",
"package_type": "pypi",
"affected_by_vulnerabilities": [],
"project": "Tool: scancode-toolkit"
"affected_by_vulnerabilities": []
},
{
"purl": "pkg:pypi/pytest",
Expand All @@ -307,8 +304,7 @@
"datafile_path": "asgiref-3.3.0-py3-none-any.whl-extract/asgiref-3.3.0.dist-info/METADATA",
"datasource_id": "pypi_wheel_metadata",
"package_type": "pypi",
"affected_by_vulnerabilities": [],
"project": "Tool: scancode-toolkit"
"affected_by_vulnerabilities": []
},
{
"purl": "pkg:pypi/pytest-asyncio",
Expand All @@ -324,8 +320,7 @@
"datafile_path": "asgiref-3.3.0-py3-none-any.whl",
"datasource_id": "pypi_wheel",
"package_type": "pypi",
"affected_by_vulnerabilities": [],
"project": "Tool: scancode-toolkit"
"affected_by_vulnerabilities": []
},
{
"purl": "pkg:pypi/pytest-asyncio",
Expand All @@ -341,8 +336,7 @@
"datafile_path": "asgiref-3.3.0-py3-none-any.whl-extract/asgiref-3.3.0.dist-info/METADATA",
"datasource_id": "pypi_wheel_metadata",
"package_type": "pypi",
"affected_by_vulnerabilities": [],
"project": "Tool: scancode-toolkit"
"affected_by_vulnerabilities": []
}
],
"files": [
Expand Down Expand Up @@ -630,8 +624,7 @@
],
"emails": [],
"urls": [],
"extra_data": {},
"project": "Tool: scancode-toolkit"
"extra_data": {}
},
{
"path": "asgiref-3.3.0-py3-none-any.whl-extract",
Expand Down Expand Up @@ -666,8 +659,7 @@
"package_data": [],
"emails": [],
"urls": [],
"extra_data": {},
"project": "Tool: scancode-toolkit"
"extra_data": {}
},
{
"path": "asgiref-3.3.0-py3-none-any.whl-extract/asgiref",
Expand Down Expand Up @@ -702,8 +694,7 @@
"package_data": [],
"emails": [],
"urls": [],
"extra_data": {},
"project": "Tool: scancode-toolkit"
"extra_data": {}
},
{
"path": "asgiref-3.3.0-py3-none-any.whl-extract/asgiref-3.3.0.dist-info",
Expand Down Expand Up @@ -738,8 +729,7 @@
"package_data": [],
"emails": [],
"urls": [],
"extra_data": {},
"project": "Tool: scancode-toolkit"
"extra_data": {}
},
{
"path": "asgiref-3.3.0-py3-none-any.whl-extract/asgiref-3.3.0.dist-info/LICENSE",
Expand Down Expand Up @@ -810,8 +800,7 @@
"package_data": [],
"emails": [],
"urls": [],
"extra_data": {},
"project": "Tool: scancode-toolkit"
"extra_data": {}
},
{
"path": "asgiref-3.3.0-py3-none-any.whl-extract/asgiref-3.3.0.dist-info/METADATA",
Expand Down Expand Up @@ -1146,8 +1135,7 @@
],
"emails": [],
"urls": [],
"extra_data": {},
"project": "Tool: scancode-toolkit"
"extra_data": {}
},
{
"path": "asgiref-3.3.0-py3-none-any.whl-extract/asgiref-3.3.0.dist-info/RECORD",
Expand Down Expand Up @@ -1184,8 +1172,7 @@
"package_data": [],
"emails": [],
"urls": [],
"extra_data": {},
"project": "Tool: scancode-toolkit"
"extra_data": {}
},
{
"path": "asgiref-3.3.0-py3-none-any.whl-extract/asgiref-3.3.0.dist-info/WHEEL",
Expand Down Expand Up @@ -1222,8 +1209,7 @@
"package_data": [],
"emails": [],
"urls": [],
"extra_data": {},
"project": "Tool: scancode-toolkit"
"extra_data": {}
},
{
"path": "asgiref-3.3.0-py3-none-any.whl-extract/asgiref-3.3.0.dist-info/top_level.txt",
Expand Down Expand Up @@ -1260,8 +1246,7 @@
"package_data": [],
"emails": [],
"urls": [],
"extra_data": {},
"project": "Tool: scancode-toolkit"
"extra_data": {}
},
{
"path": "asgiref-3.3.0-py3-none-any.whl-extract/asgiref/__init__.py",
Expand Down Expand Up @@ -1298,8 +1283,7 @@
"package_data": [],
"emails": [],
"urls": [],
"extra_data": {},
"project": "Tool: scancode-toolkit"
"extra_data": {}
},
{
"path": "asgiref-3.3.0-py3-none-any.whl-extract/asgiref/compatibility.py",
Expand Down Expand Up @@ -1336,8 +1320,7 @@
"package_data": [],
"emails": [],
"urls": [],
"extra_data": {},
"project": "Tool: scancode-toolkit"
"extra_data": {}
},
{
"path": "asgiref-3.3.0-py3-none-any.whl-extract/asgiref/current_thread_executor.py",
Expand Down Expand Up @@ -1374,8 +1357,7 @@
"package_data": [],
"emails": [],
"urls": [],
"extra_data": {},
"project": "Tool: scancode-toolkit"
"extra_data": {}
},
{
"path": "asgiref-3.3.0-py3-none-any.whl-extract/asgiref/local.py",
Expand Down Expand Up @@ -1412,8 +1394,7 @@
"package_data": [],
"emails": [],
"urls": [],
"extra_data": {},
"project": "Tool: scancode-toolkit"
"extra_data": {}
},
{
"path": "asgiref-3.3.0-py3-none-any.whl-extract/asgiref/server.py",
Expand Down Expand Up @@ -1450,8 +1431,7 @@
"package_data": [],
"emails": [],
"urls": [],
"extra_data": {},
"project": "Tool: scancode-toolkit"
"extra_data": {}
},
{
"path": "asgiref-3.3.0-py3-none-any.whl-extract/asgiref/sync.py",
Expand Down Expand Up @@ -1488,8 +1468,7 @@
"package_data": [],
"emails": [],
"urls": [],
"extra_data": {},
"project": "Tool: scancode-toolkit"
"extra_data": {}
},
{
"path": "asgiref-3.3.0-py3-none-any.whl-extract/asgiref/testing.py",
Expand Down Expand Up @@ -1526,8 +1505,7 @@
"package_data": [],
"emails": [],
"urls": [],
"extra_data": {},
"project": "Tool: scancode-toolkit"
"extra_data": {}
},
{
"path": "asgiref-3.3.0-py3-none-any.whl-extract/asgiref/timeout.py",
Expand Down Expand Up @@ -1586,8 +1564,7 @@
"package_data": [],
"emails": [],
"urls": [],
"extra_data": {},
"project": "Tool: scancode-toolkit"
"extra_data": {}
},
{
"path": "asgiref-3.3.0-py3-none-any.whl-extract/asgiref/wsgi.py",
Expand Down Expand Up @@ -1624,8 +1601,7 @@
"package_data": [],
"emails": [],
"urls": [],
"extra_data": {},
"project": "Tool: scancode-toolkit"
"extra_data": {}
}
],
"relations": []
Expand Down
Loading

0 comments on commit cf2d503

Please sign in to comment.