Skip to content

Commit 6be1c16

Browse files
authored
Fix an issue in the d2d JavaScript mapper (#1274)
* Use resource_path in Project messages for rendering as link in UI Signed-off-by: tdruez <tdruez@nexb.com> * Fix an issue in the d2d JavaScript mapper #1274 Signed-off-by: tdruez <tdruez@nexb.com> --------- Signed-off-by: tdruez <tdruez@nexb.com>
1 parent a1fdff9 commit 6be1c16

File tree

6 files changed

+14
-4
lines changed

6 files changed

+14
-4
lines changed

CHANGELOG.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ v34.6.3 (unreleased)
88
for fetching Docker images using skopeo through ``run_command_safely`` calls.
99
https://github.com/nexB/scancode.io/issues/1257
1010

11+
- Fix an issue in the d2d JavaScript mapper.
12+
https://github.com/nexB/scancode.io/pull/1274
13+
1114
v34.6.2 (2024-06-18)
1215
--------------------
1316

scanpipe/pipelines/scan_single_package.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def run_scan(self):
120120
self.project.add_error(
121121
description="\n".join(errors),
122122
model=self.pipeline_name,
123-
details={"path": resource_path},
123+
details={"resource_path": resource_path.removeprefix("codebase/")},
124124
)
125125

126126
if not scan_output_path.exists():

scanpipe/pipes/d2d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ def create_about_packages_relations(self, project):
965965

966966
if not mapped_resources:
967967
error_message_details = {
968-
"path": about_path,
968+
"resource_path": about_path,
969969
"package_data": package_data,
970970
}
971971
project.add_warning(

scanpipe/pipes/js.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def get_minified_resource(map_resource, minified_resources):
192192
"""
193193
path = Path(map_resource.path.lstrip("/"))
194194

195-
minified_file, _ = path.name.split(".map")
195+
minified_file = path.name.removesuffix(".map")
196196
minified_file_path = path.parent / minified_file
197197
minified_resource = minified_resources.get_or_none(path=minified_file_path)
198198

scanpipe/templates/scanpipe/message_list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<td style="max-width: 250px;">
3131
<div style="max-height: 200px; overflow-y: scroll;">
3232
{% if message.description|length < 100 %}
33-
<a href="?message={{ message.description }}" class="is-black-link">{{ message.description }}</a>
33+
<a href="?description={{ message.description }}" class="is-black-link">{{ message.description }}</a>
3434
{% else %}
3535
{{ message.description }}
3636
{% endif %}

scanpipe/tests/pipes/test_js.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from scanpipe.pipes.input import copy_input
3131
from scanpipe.pipes.input import copy_inputs
3232
from scanpipe.pipes.pathmap import build_index
33+
from scanpipe.tests import make_resource_file
3334

3435

3536
class ScanPipeJsTest(TestCase):
@@ -181,6 +182,12 @@ def test_scanpipe_pipes_js_get_minified_resource(self):
181182

182183
self.assertEqual(expected, result)
183184

185+
def test_scanpipe_pipes_js_get_minified_resource_multiple_map_occurrences(self):
186+
resource = make_resource_file(self.project1, "main.map.js.map")
187+
self.assertIsNone(
188+
js.get_minified_resource(resource, self.project1.codebaseresources.all())
189+
)
190+
184191
def test_scanpipe_pipes_js_get_matches_by_ratio(self):
185192
to_dir = (
186193
self.project1.codebase_path / "to/project.tar.zst-extract/osgi/marketplace/"

0 commit comments

Comments
 (0)