Skip to content

Commit cdf6d00

Browse files
committed
Merge branch 'main' into 237-custom-pipelines-docs
2 parents ae97100 + 813ea53 commit cdf6d00

15 files changed

+234
-44
lines changed

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
### unreleased
55

6+
- Add ability to register custom pipelines through a new SCANCODEIO_PIPELINES_DIRS
7+
setting.
8+
https://github.com/nexB/scancode.io/issues/237
9+
610
- Add a pipeline `scan_package.ScanPackage` to scan a single package archive with
711
ScanCode-toolkit.
812
https://github.com/nexB/scancode.io/issues/25

docs/introduction.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ that are adapted to a software project's unique context and technology platform
3232
can be difficult. This will require deploying and running multiple specialized
3333
tools and merge their results with a consistent workflow. Moreover,
3434
when reusing thousands of open source packages is becoming commonplace,
35-
code scans pipelines need to be scripted as code and running on servers backed
35+
code scans pipelines need to be scripted as code is running on servers backed
3636
by a shared database, not on a laptop.
3737

3838
For instance, when you analyze Docker container images, there could be hundreds
3939
to thousands of system packages, such as Debian, RPM, Alpine, and application
4040
packages, including npm, PyPI, Rubygems, Maven, installed in an image
41-
side-by-side with your own code. Taking care of all these can be
41+
side-by-side with your own code. Taking care of all this can be
4242
an extremely hard task, and that's when **ScanCode.io** comes into play to help
4343
organizing these complex code analysis as scripted pipelines and store their
44-
results in a uniform database for automated code analysis.
44+
results in a database for automated code analysis.
4545

4646

4747
What is ScanPipe?
@@ -73,9 +73,10 @@ are planning to start a new one, consider the following questions:
7373
2. **Complexity**: Does the project use many third-party components or technologies?
7474
3. **Reproducibility**: Is it important that the results are reproducible, traceable, and auditable?
7575

76-
If you answered "yes" to any of the above, keep reading - ScanPipe can help you.
77-
If the answer is "no" to all of the above, which is a valid scenario, e.g., when you
78-
are doing small-scale analysis, ScanPipe may provide only limited benefit for you.
76+
If you answered **"yes"** to any of the above, keep reading - ScanPipe can help
77+
you. If the answer is **"no"** to all of the above, which is a valid scenario,
78+
e.g., when you are doing small-scale analysis, ScanPipe may provide only limited
79+
benefit for you.
7980

8081
The first set of available pipelines helps automate the analysis of Docker
8182
container images and virtual machine (VM) disk images that often harbor

docs/run-docker.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ create an environment file, and build the Docker image::
2727
docker-compose build
2828

2929
.. note::
30-
The image will need to be re-build when the ScanCode.io app source code if
31-
modified or updated.
30+
The image will need to be re-build when the ScanCode.io source code is modified or
31+
updated.
3232

3333
Run the Image
3434
-------------

docs/scancodeio-settings.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ of parallel processes to 4::
7474

7575
SCANCODE_DEFAULT_OPTIONS=--processes 4,--timeout 120
7676

77+
SCANCODEIO_PIPELINES_DIRS
78+
-------------------------
79+
80+
This setting defines the additional locations ScanCode.io will search for pipelines.
81+
This should be set to a list of comma-separated strings that contain full paths to your additional
82+
pipelines directories::
83+
84+
SCANCODEIO_PIPELINES_DIRS=/var/scancodeio/pipelines/,/home/user/pipelines/
85+
7786
SCANCODEIO_POLICIES_FILE
7887
------------------------
7988

docs/scanpipe-output.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. _scanpipe_output:
22

3-
Output
4-
======
3+
Output Files
4+
============
55

66
Whether you use the command line or the web application to run your
77
scans, the generated results are available for review or export in

docs/scanpipe-pipelines.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,8 @@ Scan Codebase
2929
-------------
3030
.. autoclass:: scanpipe.pipelines.scan_codebase.ScanCodebase()
3131
:members:
32+
33+
Scan Package
34+
------------
35+
.. autoclass:: scanpipe.pipelines.scan_package.ScanPackage()
36+
:members:

docs/tutorial-1.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. _tutorial_1:
22

3-
Docker Image Analysis (command line)
4-
====================================
3+
Analyze Docker Image (command line)
4+
===================================
55

66
In this tutorial, you will learn by example how to use ScanCode.io to analyze
77
a test Docker image by following the given steps and, along the way,

docs/tutorial-2.rst

Lines changed: 84 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,69 @@
11
.. _tutorial_2:
22

3-
Scan Codebase (command line)
4-
============================
3+
Analyze Codebase (command line)
4+
===============================
5+
6+
The focus of this tutorial is to guide you through scanning a codebase package
7+
using ScanCode.io.
8+
9+
.. note::
10+
This tutorial assumes you have a current version of ScanCode.io installed
11+
locally on your machine. If you do not have it installed,
12+
see our :ref:`installation` guide for instructions.
513

614
Requirements
715
------------
16+
Before you follow the instructions in this tutorial, you need to:
817

9-
- **ScanCode.io is installed**, see :ref:`installation`
10-
- **Shell access** on the machine where ScanCode.io is installed
18+
- Install **ScanCode.io** locally
19+
- Download the following **package archive** and save it to your home directory: `asgiref-3.3.0-py3-none-any.whl <https://files.pythonhosted.org/packages/c0/e8/578887011652048c2d273bf98839a11020891917f3aa638a0bc9ac04d653/asgiref-3.3.0-py3-none-any.whl>`_
20+
- Have **Shell access** on the machine where ScanCode.io is installed
1121

22+
Instructions
23+
------------
1224

13-
Before you start
14-
----------------
25+
- Open a shell in the ScanCode.io installation directory and activate the
26+
virtual environment - **virtualenv**:
1527

16-
Download the following package archive save this in your home directory:
17-
`asgiref-3.3.0-py3-none-any.whl <https://files.pythonhosted.org/packages/c0/e8/578887011652048c2d273bf98839a11020891917f3aa638a0bc9ac04d653/asgiref-3.3.0-py3-none-any.whl>`_
28+
.. code-block:: console
1829
30+
$ source bin/activate
1931
20-
Step-by-step
21-
------------
32+
.. code-block:: console
2233
23-
- Open a shell in the ScanCode.io installation directory and activate the virtualenv::
34+
>> (scancodeio) $
2435
25-
$ source bin/activate
36+
- Create a new project named ``asgiref``:
2637

27-
- The following command will create a new project named ``asgiref``,
28-
add the archive as an input for the project,
29-
add the ``scan_codebase`` pipeline, and execute it::
38+
.. code-block:: console
3039
31-
$ scanpipe create-project asgiref \
32-
--input-file ~/asgiref-3.3.0-py3-none-any.whl \
33-
--pipeline scan_codebase \
34-
--execute
40+
$ scanpipe create-project asgiref
41+
42+
.. code-block:: console
43+
44+
>> Project asgiref created with work directory projects/asgiref-072c89db
45+
46+
- Add the package archive to the project workspace's :guilabel:`input/`
47+
directory:
48+
49+
.. code-block:: bash
50+
51+
$ scanpipe add-input --project asgiref --input-file ~/asgiref-3.3.0-py3-none-any.whl
52+
53+
.. code-block:: console
54+
55+
>> File(s) copied to the project inputs directory:
56+
- asgiref-3.3.0-py3-none-any.whl
57+
58+
- Add the ``scan_codebase`` pipeline to your project:
59+
60+
.. code-block:: console
61+
62+
$ scanpipe add-pipeline --project asgiref scan_codebase
63+
64+
.. code-block:: console
65+
66+
>> Pipeline(s) added to the project
3567
3668
.. note::
3769
The content of the :guilabel:`input/` directory will be copied in the
@@ -41,5 +73,36 @@ Step-by-step
4173
:guilabel:`codebase/` directory in which case the ``--input`` option can be
4274
omitted.
4375

44-
- The scan results as JSON and CSV will be available in the project
45-
:guilabel:`output/` directory.
76+
- Run the ``scan_codebase`` pipeline on your project. The pipeline execution
77+
progress is shown within the following command's output:
78+
79+
.. code-block:: bash
80+
81+
$ scanpipe execute --project asgiref
82+
83+
.. code-block:: console
84+
85+
>> Pipeline scan_codebase run in progress..
86+
2021-07-12 17:45:53.85 Pipeline [scan_codebase] starting
87+
2021-07-12 17:45:53.85 Step [copy_inputs_to_codebase_directory] starting
88+
2021-07-12 17:45:53.86 Step [copy_inputs_to_codebase_directory] completed in 0.00 seconds
89+
2021-07-12 17:45:53.86 Step [run_extractcode] starting
90+
[...]
91+
2021-07-12 17:46:01.61 Pipeline completed
92+
93+
- Finally, you can view your scan results in JSON or CSV file formats inside
94+
the project's :guilabel:`output/` directory.
95+
96+
.. tip::
97+
The ``inputs`` and ``pipelines`` can be provided at the same time when
98+
calling the ``create-project`` command. For instance, the following command
99+
will create a new project named ``asgiref``, add the package archive as the
100+
project input, add the ``scan_codebase`` pipeline to the project, and
101+
execute it:
102+
103+
.. code-block:: bash
104+
105+
$ scanpipe create-project asgiref \
106+
--input-file ~/asgiref-3.3.0-py3-none-any.whl \
107+
--pipeline scan_codebase \
108+
--execute

docs/user-interface.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ to your project by clicking the **"Add inputs"** and **"Add pipeline"** buttons.
9090
.. image:: images/UI-4-new.png
9191

9292
.. warning::
93-
You will not be able to add more inputs once a pipeline has been run on the project.
94-
You can add and run more pipelines though.
93+
You will not be able to add any extra inputs once a pipeline has been run on
94+
the project. However, you still can add and run extra pipelines as needed!
9595

9696
Within each project, you can view your project details, review the results of
9797
the pipeline execution, or download the output files.

scancodeio/settings/base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@
5353

5454
SCANCODEIO_POLICIES_FILE = env.str("SCANCODEIO_POLICIES_FILE", default="policies.yml")
5555

56+
# This setting defines the additional locations ScanCode.io will search for pipelines.
57+
# This should be set to a list of strings that contain full paths to your additional
58+
# pipelines directories.
59+
SCANCODEIO_PIPELINES_DIRS = env.list("SCANCODEIO_PIPELINES_DIRS", default=[])
60+
5661
# Application definition
5762

5863
INSTALLED_APPS = (

0 commit comments

Comments
 (0)