Skip to content

Commit 528be96

Browse files
Merge branch 'main' into exclusion-framework-ruby
Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
2 parents a185d7d + 95da828 commit 528be96

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1278
-315
lines changed

CHANGELOG.rst

+32-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
Changelog
22
=========
33

4-
v34.9.4 (unreleased)
4+
v34.9.5 (unreleased)
5+
--------------------
6+
7+
- Add support for the XLSX report in REST API.
8+
https://github.com/aboutcode-org/scancode.io/issues/1524
9+
10+
- Add options to the Project reset action.
11+
Also, the Project labels are kept during reset.
12+
https://github.com/aboutcode-org/scancode.io/issues/1568
13+
14+
v34.9.4 (2025-01-21)
515
--------------------
616

717
- Improve Project list page navigation.
@@ -47,6 +57,27 @@ v34.9.4 (unreleased)
4757
sheets with a dedicated VULNERABILITIES sheet.
4858
https://github.com/aboutcode-org/scancode.io/issues/1519
4959

60+
- Keep the InputSource objects when using ``reset`` on Projects.
61+
https://github.com/aboutcode-org/scancode.io/issues/1536
62+
63+
- Add a ``report`` management command that allows to generate XLSX reports for
64+
multiple projects at once using labels and searching by project name.
65+
https://github.com/aboutcode-org/scancode.io/issues/1524
66+
67+
- Add the ability to "select across" in Projects list when using the "select all"
68+
checkbox on paginated list.
69+
https://github.com/aboutcode-org/scancode.io/issues/1524
70+
71+
- Update scancode-toolkit to v32.3.2. See CHANGELOG for updates:
72+
https://github.com/aboutcode-org/scancode-toolkit/releases/tag/v32.3.2
73+
https://github.com/aboutcode-org/scancode-toolkit/releases/tag/v32.3.1
74+
75+
- Adds a project settings ``scan_max_file_size`` and a scancode.io settings field
76+
``SCANCODEIO_SCAN_MAX_FILE_SIZE`` to skip scanning files above a certain
77+
file size (in bytes) as a temporary fix for large memory spikes while
78+
scanning for licenses in certain large files.
79+
https://github.com/aboutcode-org/scancode-toolkit/issues/3711
80+
5081
v34.9.3 (2024-12-31)
5182
--------------------
5283

docs/application-settings.rst

+12
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,18 @@ The value unit is second and is defined as an integer::
165165

166166
Default: ``120`` (2 minutes)
167167

168+
SCANCODEIO_SCAN_MAX_FILE_SIZE
169+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
170+
171+
Maximum file size allowed for a file to be scanned when scanning a codebase.
172+
173+
The value unit is bytes and is defined as an integer, see the following
174+
example of setting this at 5 MB::
175+
176+
SCANCODEIO_SCAN_MAX_FILE_SIZE=5242880
177+
178+
Default: ``None`` (all files will be scanned)
179+
168180
.. _scancodeio_settings_pipelines_dirs:
169181

170182
SCANCODEIO_PIPELINES_DIRS

docs/command-line-interface.rst

+64-5
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ ScanPipe's own commands are listed under the ``[scanpipe]`` section::
6868
list-project
6969
output
7070
purldb-scan-worker
71+
report
7172
reset-project
7273
run
7374
show-pipeline
@@ -174,6 +175,10 @@ Required arguments (one of):
174175
| project-2 | pkg:deb/debian/[email protected] |
175176
+----------------+---------------------------------+
176177

178+
.. tip::
179+
In place of a local path, a download URL to the CSV file is supported for the
180+
``--input-list`` argument.
181+
177182
Optional arguments:
178183

179184
- ``--project-name-suffix`` Optional custom suffix to append to project names.
@@ -194,14 +199,15 @@ Optional arguments:
194199
Example: Processing Multiple Docker Images
195200
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
196201

197-
Assume multiple Docker images are available in a directory named ``local-data/`` on
202+
Suppose you have multiple Docker images stored in a directory named ``local-data/`` on
198203
the host machine.
199-
To process these images with the ``analyze_docker_image`` pipeline using asynchronous
200-
execution::
204+
To process these images using the ``analyze_docker_image`` pipeline with asynchronous
205+
execution, you can use this command::
201206

202207
$ docker compose run --rm \
203-
--volume local-data/:/input-data:ro \
204-
web scanpipe batch-create input-data/ \
208+
--volume local-data/:/input-data/:ro \
209+
web scanpipe batch-create
210+
--input-directory /input-data/ \
205211
--pipeline analyze_docker_image \
206212
--label "Docker" \
207213
--execute --async
@@ -224,6 +230,19 @@ Each Docker image in the ``local-data/`` directory will result in the creation o
224230
project with the specified pipeline (``analyze_docker_image``) executed by worker
225231
services.
226232

233+
Example: Processing Multiple Develop to Deploy Mapping
234+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
235+
236+
To process an input list CSV file with the ``map_deploy_to_develop`` pipeline using
237+
asynchronous execution::
238+
239+
$ docker compose run --rm \
240+
web scanpipe batch-create \
241+
--input-list https://url/input_list.csv \
242+
--pipeline map_deploy_to_develop \
243+
--label "d2d_mapping" \
244+
--execute --async
245+
227246
`$ scanpipe list-pipeline [--verbosity {0,1,2,3}]`
228247
--------------------------------------------------
229248

@@ -375,6 +394,46 @@ your outputs on the host machine when running with Docker.
375394
.. tip:: To specify a CycloneDX spec version (default to latest), use the syntax
376395
``cyclonedx:VERSION`` as format value. For example: ``--format cyclonedx:1.5``.
377396

397+
.. _cli_report:
398+
399+
`$ scanpipe report --model MODEL`
400+
---------------------------------
401+
402+
Generates an XLSX report of selected projects based on the provided criteria.
403+
404+
Required arguments:
405+
406+
- ``--model {package,dependency,resource,relation,message,todo}``
407+
Specifies the model to include in the XLSX report. Available choices are based on
408+
predefined object types.
409+
410+
Optional arguments:
411+
412+
- ``--output-directory OUTPUT_DIRECTORY``
413+
The path to the directory where the report file will be created. If not provided,
414+
the report file will be created in the current working directory.
415+
416+
- ``--search SEARCH``
417+
Filter projects by searching for the provided string in their name.
418+
419+
- ``--label LABELS``
420+
Filter projects by the provided label(s). Multiple labels can be provided by using
421+
this argument multiple times.
422+
423+
.. note::
424+
Either ``--label`` or ``--search`` must be provided to select projects.
425+
426+
Example usage:
427+
428+
1. Generate a report for all projects tagged with "d2d" and include the **TODOS**
429+
worksheet::
430+
431+
$ scanpipe report --model todo --label d2d
432+
433+
2. Generate a report for projects whose names contain the word "audit" and include the
434+
**PACKAGES** worksheet::
435+
436+
$ scanpipe report --model package --search audit
378437

379438
.. _cli_check_compliance:
380439

docs/installation.rst

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ Build the Image
3535
ScanCode.io is distributed with ``Dockerfile`` and ``docker-compose.yml`` files
3636
required for the creation of the Docker image.
3737

38+
.. note::
39+
On **Windows**, ensure to use the **wsl** (Windows Subsystem for Linux) for
40+
the installation process.
41+
3842
.. warning:: On **Windows**, ensure that git ``autocrlf`` configuration is set to
3943
``false`` before cloning the repository::
4044

docs/project-configuration.rst

+19
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Content of a ``scancode-config.yml`` file:
5454
ignored_patterns:
5555
- '*.tmp'
5656
- 'tests/*'
57+
scan_max_file_size: 5242880
5758
ignored_dependency_scopes:
5859
- package_type: npm
5960
scope: devDependencies
@@ -86,6 +87,24 @@ product_version
8687

8788
The product version of this project, as specified within the DejaCode application.
8889

90+
scan_max_file_size
91+
^^^^^^^^^^^^^^^^^^
92+
93+
Maximum file size allowed for a file to be scanned when scanning a codebase.
94+
95+
The value unit is bytes and is defined as an integer, see the following
96+
example of setting this at 5 MB::
97+
98+
scan_max_file_size=5242880
99+
100+
Default is ``None``, in which case all files will be scanned.
101+
102+
.. note::
103+
This is the same as the scancodeio setting ``SCANCODEIO_SCAN_MAX_FILE_SIZE``
104+
set using the .env file, and the project setting ``scan_max_file_size`` takes
105+
precedence over the scancodeio setting ``SCANCODEIO_SCAN_MAX_FILE_SIZE``.
106+
107+
89108
ignored_patterns
90109
^^^^^^^^^^^^^^^^
91110

docs/rest-api.rst

+37
Original file line numberDiff line numberDiff line change
@@ -587,3 +587,40 @@ This action deletes a "not started" or "queued" pipeline run.
587587
{
588588
"status": "Pipeline pipeline_name deleted."
589589
}
590+
591+
XLSX Report
592+
-----------
593+
594+
Generates an XLSX report for selected projects based on specified criteria. The
595+
``model`` query parameter is required to determine the type of data to include in the
596+
report.
597+
598+
Endpoint:
599+
``GET /api/projects/report/?model=MODEL``
600+
601+
Parameters:
602+
603+
- ``model``: Defines the type of data to include in the report.
604+
Accepted values: ``package``, ``dependency``, ``resource``, ``relation``, ``message``,
605+
``todo``.
606+
607+
.. note::
608+
609+
You can apply any available filters to select the projects to include in the
610+
report. Filters can be based on project attributes, such as a substring in the
611+
name or specific labels.
612+
613+
Example Usage:
614+
615+
1. Generate a report for projects tagged with "d2d" and include the ``TODOS`` worksheet:
616+
617+
.. code-block::
618+
619+
GET /api/projects/report/?model=todo&label=d2d
620+
621+
2. Generate a report for projects whose names contain "audit" and include the
622+
``PACKAGES`` worksheet:
623+
624+
.. code-block::
625+
626+
GET /api/projects/report/?model=package&name__contains=audit

scancodeio/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
import git
3030

31-
VERSION = "34.9.3"
31+
VERSION = "34.9.4"
3232

3333
PROJECT_DIR = Path(__file__).resolve().parent
3434
ROOT_DIR = PROJECT_DIR.parent

scancodeio/settings.py

+3
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@
100100
# Default to 2 minutes.
101101
SCANCODEIO_SCAN_FILE_TIMEOUT = env.int("SCANCODEIO_SCAN_FILE_TIMEOUT", default=120)
102102

103+
# Default to None which scans all files
104+
SCANCODEIO_SCAN_MAX_FILE_SIZE = env.int("SCANCODEIO_SCAN_MAX_FILE_SIZE", default=None)
105+
103106
# List views pagination, controls the number of items displayed per page.
104107
# Syntax in .env: SCANCODEIO_PAGINATE_BY=project=10,project_error=10
105108
SCANCODEIO_PAGINATE_BY = env.dict(

scancodeio/static/main.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ function setupSelectCheckbox() {
232232
updateButtonAndDropdownState();
233233

234234
// Check if all row checkboxes are checked and update the "Select All" checkbox accordingly
235-
selectAllCheckbox.checked = Array.from(rowCheckboxes).every((cb) => cb.checked);
235+
const allRowCheckboxesChecked = Array.from(rowCheckboxes).every((cb) => cb.checked);
236+
selectAllCheckbox.checked = allRowCheckboxesChecked;
236237
});
237238
});
238239

scanpipe/api/views.py

+41
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
from scanpipe.models import Project
5353
from scanpipe.models import Run
5454
from scanpipe.models import RunInProgressError
55+
from scanpipe.pipes import filename_now
5556
from scanpipe.pipes import output
5657
from scanpipe.pipes.compliance import get_project_compliance_alerts
5758
from scanpipe.views import project_results_json_response
@@ -79,6 +80,11 @@ class ProjectFilterSet(django_filters.rest_framework.FilterSet):
7980
method="filter_names",
8081
)
8182
uuid = django_filters.CharFilter()
83+
label = django_filters.CharFilter(
84+
label="Label",
85+
field_name="labels__slug",
86+
distinct=True,
87+
)
8288

8389
class Meta:
8490
model = Project
@@ -90,6 +96,7 @@ class Meta:
9096
"names",
9197
"uuid",
9298
"is_archived",
99+
"label",
93100
]
94101

95102
def filter_names(self, qs, name, value):
@@ -195,6 +202,40 @@ def pipelines(self, request, *args, **kwargs):
195202
]
196203
return Response(pipeline_data)
197204

205+
@action(detail=False)
206+
def report(self, request, *args, **kwargs):
207+
project_qs = self.filter_queryset(self.get_queryset())
208+
209+
model_choices = list(output.object_type_to_model_name.keys())
210+
model = request.GET.get("model")
211+
if not model:
212+
message = {
213+
"error": (
214+
"Specifies the model to include in the XLSX report. "
215+
"Using: ?model=MODEL"
216+
),
217+
"choices": ", ".join(model_choices),
218+
}
219+
return Response(message, status=status.HTTP_400_BAD_REQUEST)
220+
221+
if model not in model_choices:
222+
message = {
223+
"error": f"{model} is not on of the valid choices",
224+
"choices": ", ".join(model_choices),
225+
}
226+
return Response(message, status=status.HTTP_400_BAD_REQUEST)
227+
228+
output_file = output.get_xlsx_report(
229+
project_qs=project_qs,
230+
model_short_name=model,
231+
)
232+
output_file.seek(0)
233+
return FileResponse(
234+
output_file,
235+
filename=f"scancodeio-report-{filename_now()}.xlsx",
236+
as_attachment=True,
237+
)
238+
198239
def get_filtered_response(
199240
self, request, queryset, filterset_class, serializer_class
200241
):

0 commit comments

Comments
 (0)