Skip to content

Commit f56daa2

Browse files
Add support for pipeline "selected_groups" in the run cli #1306 (#1307)
* Add selected_groups in the API RunSerializer #1306 Signed-off-by: tdruez <tdruez@nexb.com> * Add support for providing selected_groups in the ``run`` cli #1306 Signed-off-by: tdruez <tdruez@nexb.com> * Rename the Resolver groups with a no-spaces syntax #1306 Signed-off-by: tdruez <tdruez@nexb.com> * Reset the FIXTURES_REGEN to False #1306 Signed-off-by: tdruez <tdruez@nexb.com> * Update CLI end-to-end scanning docs to use groups Reference: #1302 Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com> * Fix test failures Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com> --------- Signed-off-by: tdruez <tdruez@nexb.com> Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com> Co-authored-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
1 parent af15beb commit f56daa2

25 files changed

+91
-30
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ v34.6.4 (unreleased)
1515
related work directories created more than a specified number of days ago.
1616
https://github.com/nexB/scancode.io/issues/1289
1717

18-
- Update the ``inspect_packages`` pipeline to have an optional ``Static Resolver``
18+
- Update the ``inspect_packages`` pipeline to have an optional ``StaticResolver``
1919
group to create resolved packages and dependency relationships from lockfiles
2020
and manifests having pre-resolved dependencies. Also update this pipeline to
2121
perform package assembly from multiple manifests and files to create
2222
discovered packages. Also update the ``resolve_dependencies`` pipeline to have
23-
the same ``Static Resolver`` group and mode the dynamic resolution part to a new
24-
optional ``Dynamic Resolver`` group.
23+
the same ``StaticResolver`` group and mode the dynamic resolution part to a new
24+
optional ``DynamicResolver`` group.
2525
See https://github.com/nexB/scancode.io/pull/1244
2626

2727
- Add a new attribute ``is_direct`` to the DiscoveredDependency model and two new
@@ -34,6 +34,9 @@ v34.6.4 (unreleased)
3434
and improvements see https://github.com/nexB/scancode-toolkit/releases/tag/v32.2.0
3535
and https://github.com/nexB/scancode-toolkit/releases/tag/v32.2.1
3636

37+
- Add support for providing pipeline "selected_groups" in the ``run`` entry point.
38+
https://github.com/nexB/scancode.io/issues/1306
39+
3740
v34.6.3 (2024-06-21)
3841
--------------------
3942

docs/command-line-interface.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,16 +354,16 @@ Optional arguments:
354354

355355
.. _cli_run:
356356

357-
`$ run PIPELINE_NAME INPUT_LOCATION`
358-
------------------------------------
357+
`$ run PIPELINE_NAME [PIPELINE_NAME ...] input_location`
358+
--------------------------------------------------------
359359

360360
A ``run`` command is available for executing pipelines and printing the results
361361
without providing any configuration. This can be useful for running a pipeline to get
362362
the results without the need to persist the data in the database or access the UI to
363363
review the results.
364364

365-
.. tip:: You can run multiple pipelines by providing their names, comma-separated,
366-
such as `pipeline1,pipeline2`.
365+
.. tip:: You can run multiple pipelines by providing their names, space-separated,
366+
such as `pipeline1 pipeline2`.
367367

368368
Optional arguments:
369369

@@ -378,12 +378,16 @@ For example, running the ``inspect_packages`` pipeline on a manifest file:
378378
379379
$ run inspect_packages path/to/package.json > results.json
380380
381+
.. tip:: Use the "pipeline_name:group1,group2" syntax to select steps groups::
382+
383+
$ run inspect_packages:StaticResolver package.json > results.json
384+
381385
In the following example, running the ``scan_codebase`` followed by the
382386
``find_vulnerabilities`` pipelines on a codebase directory:
383387

384388
.. code-block:: bash
385389
386-
$ run scan_codebase,find_vulnerabilities path/to/codebase/ > results.json
390+
$ run scan_codebase find_vulnerabilities path/to/codebase/ > results.json
387391
388392
Using a URL as input is also supported:
389393

docs/tutorial_cli_end_to_end_scanning_to_dejacode.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
Analyze Codebase End to End with DepLock and DejaCode (Command Line)
44
=====================================================================
55

6-
The focus of this tutorial is to guide you through scanning a codebase end to end, starting with the
7-
dependency resolution, through the scanning proper, and finally the upload of the scan in DejaCode,
8-
using DepLock and ScanCode.io.
6+
The focus of this tutorial is to guide you through scanning a codebase end to end,
7+
starting with the dependency resolution, through the scanning proper, and finally
8+
the upload of the scan in DejaCode, using DepLock and ScanCode.io.
99

1010
This is designed to run a faster, simple **inspect_packages** ScanCode.io pipeline.
1111

@@ -50,7 +50,7 @@ The process for this tutorial is to:
5050

5151

5252
.. note::
53-
Below instructions have been tested on Linux for now.
53+
Below instructions have been tested only on Linux for now.
5454

5555

5656
Fetch codebase to scan
@@ -146,14 +146,15 @@ Run ScanCode Package Detection
146146
-------------------------------
147147

148148
Execute the following command to run the ScanCode scanner
149-
with **inspect_packages** pipeline on codebase in our current directory.
149+
with **inspect_packages** pipeline with static resolution
150+
on the codebase in our current directory.
150151

151152
.. code-block:: shell
152153
153154
docker run --rm \
154155
-v "$(pwd)":/code \
155156
ghcr.io/nexb/scancode.io:latest \
156-
sh -c "run inspect_packages /code" \
157+
sh -c "run inspect_packages:StaticResolver /code" \
157158
> results.json
158159
159160

scanpipe/api/serializers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ class Meta:
113113
"pipeline_name",
114114
"status",
115115
"description",
116+
"selected_groups",
116117
"project",
117118
"uuid",
118119
"created_date",

scanpipe/management/commands/run.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,16 @@ class Command(BaseCommand):
3535

3636
def add_arguments(self, parser):
3737
super().add_arguments(parser)
38-
parser.add_argument("pipelines", help="Pipelines to run, comma-separated.")
38+
parser.add_argument(
39+
"pipelines",
40+
metavar="PIPELINE_NAME",
41+
nargs="+",
42+
help=(
43+
"One or more pipeline to run. "
44+
"The pipelines executed based on their given order. "
45+
'Groups can be provided using the "pipeline_name:group1,group2" syntax.'
46+
),
47+
)
3948
parser.add_argument(
4049
"input_location", help="Input location: file, directory, and URL supported."
4150
)
@@ -49,7 +58,6 @@ def add_arguments(self, parser):
4958

5059
def handle(self, *args, **options):
5160
pipelines = options["pipelines"]
52-
pipelines = [pipeline_name.strip() for pipeline_name in pipelines.split(",")]
5361
input_location = options["input_location"]
5462
output_format = options["format"]
5563
# Generate a random name for the project if not provided

scanpipe/pipelines/inspect_packages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def scan_for_application_packages(self):
6565
progress_logger=self.log,
6666
)
6767

68-
@group("Static Resolver")
68+
@group("StaticResolver")
6969
def resolve_dependencies(self):
7070
"""
7171
Create packages and dependency relationships from

scanpipe/pipelines/resolve_dependencies.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def get_manifest_inputs(self):
5757
"""Locate package manifest files with a supported package resolver."""
5858
self.manifest_resources = resolve.get_manifest_resources(self.project)
5959

60-
@group("Static Resolver")
60+
@group("StaticResolver")
6161
def scan_for_application_packages(self):
6262
"""
6363
Scan and assemble application packages from package manifests
@@ -70,15 +70,15 @@ def scan_for_application_packages(self):
7070
progress_logger=self.log,
7171
)
7272

73-
@group("Static Resolver")
73+
@group("StaticResolver")
7474
def create_packages_and_dependencies(self):
7575
"""
7676
Create the statically resolved packages and their dependencies
7777
in the database.
7878
"""
7979
scancode.process_package_data(self.project, static_resolve=True)
8080

81-
@group("Dynamic Resolver")
81+
@group("DynamicResolver")
8282
def get_packages_from_manifest(self):
8383
"""
8484
Resolve package data from lockfiles/requirement files with package
@@ -91,7 +91,7 @@ def get_packages_from_manifest(self):
9191
model="get_packages_from_manifest",
9292
)
9393

94-
@group("Dynamic Resolver")
94+
@group("DynamicResolver")
9595
def create_resolved_packages(self):
9696
"""
9797
Create the dynamically resolved packages and their dependencies

scanpipe/tests/data/asgiref/asgiref-3.3.0_load_inventory_expected.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
{
1616
"pipeline_name": "load_inventory",
1717
"status": "not_started",
18+
"selected_groups": null,
1819
"scancodeio_version": "",
1920
"task_id": null,
2021
"task_start_date": null,

scanpipe/tests/data/d2d/about_files/expected.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
{
2222
"pipeline_name": "map_deploy_to_develop",
2323
"status": "not_started",
24+
"selected_groups": null,
2425
"scancodeio_version": "",
2526
"task_id": null,
2627
"task_start_date": null,
@@ -71,9 +72,9 @@
7172
"notice_text": "",
7273
"source_packages": [],
7374
"extra_data": {},
75+
"package_uid": "pkg:local-files/analysis-90cb6382/90cb6382-431c-4187-be76-d4f1a2199a2f?uuid=fixed-uid-done-for-testing-5642512d1758",
7476
"is_private": false,
7577
"is_virtual": false,
76-
"package_uid": "pkg:local-files/analysis-90cb6382/90cb6382-431c-4187-be76-d4f1a2199a2f?uuid=fixed-uid-done-for-testing-5642512d1758",
7778
"datasource_ids": [],
7879
"datafile_paths": [],
7980
"file_references": [],
@@ -124,9 +125,9 @@
124125
"*flume-ng-node-*.jar-extract/org/apache/flume/node/ConfigurationProvider.class"
125126
]
126127
},
128+
"package_uid": "pkg:maven/log4j/log4j@1.2.13?uuid=fixed-uid-done-for-testing-5642512d1758",
127129
"is_private": false,
128130
"is_virtual": false,
129-
"package_uid": "pkg:maven/log4j/log4j@1.2.13?uuid=fixed-uid-done-for-testing-5642512d1758",
130131
"datasource_ids": [],
131132
"datafile_paths": [],
132133
"file_references": [],

scanpipe/tests/data/d2d/flume-ng-node-d2d.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
{
2222
"pipeline_name": "map_deploy_to_develop",
2323
"status": "not_started",
24+
"selected_groups": null,
2425
"scancodeio_version": "",
2526
"task_id": null,
2627
"task_start_date": null,
@@ -71,9 +72,9 @@
7172
"notice_text": "",
7273
"source_packages": [],
7374
"extra_data": {},
75+
"package_uid": "pkg:local-files/analysis-b74fe5df/b74fe5df-e965-415e-ba65-f38421a0695d?uuid=fixed-uid-done-for-testing-5642512d1758",
7476
"is_private": false,
7577
"is_virtual": false,
76-
"package_uid": "pkg:local-files/analysis-b74fe5df/b74fe5df-e965-415e-ba65-f38421a0695d?uuid=fixed-uid-done-for-testing-5642512d1758",
7778
"datasource_ids": [],
7879
"datafile_paths": [],
7980
"file_references": [],

0 commit comments

Comments
 (0)