3
3
License Policies and Compliance Alerts
4
4
======================================
5
5
6
- In this tutorial, we'll introduce ScanCode.io's **license policies ** and ** compliance
7
- alerts ** system and use the **results of a pipeline run ** to demonstrate an example
8
- of the license policies and compliance alerts output.
6
+ In this tutorial, we'll introduce ScanCode.io's **license policies ** and
7
+ ** compliance alerts ** system and use the **results of a pipeline run ** to demonstrate
8
+ an example of the license policies and compliance alerts output.
9
9
10
- As already mentioned, ScanCode.io automates the process of ** Software Composition
11
- Analysis "SCA" ** to identify existing open source components and their license
12
- compliance data in an application's codebase.
10
+ As already mentioned, ScanCode.io automates the process of
11
+ ** Software Composition Analysis "SCA" ** to identify existing open source components
12
+ and their license compliance data in an application's codebase.
13
13
14
14
ScanCode.io also gives users the ability to define a set of **license policies ** to
15
15
have their projects checked against with a **compliance system **.
16
16
17
- Creating Policies Files
18
- -----------------------
17
+ Refer to :ref: `policies ` for details about the policies system.
19
18
20
- A valid policies file is required to **enable compliance-related features **.
19
+ Instructions
20
+ ------------
21
21
22
- The policies file, by default ``policies.yml ``, is a **YAML file ** with a structure
23
- similar to the following:
22
+ Create a ``policies.yml `` file with the following content:
24
23
25
24
.. code-block :: yaml
26
25
27
26
license_policies :
28
27
- license_key : mit
29
28
label : Approved License
30
29
compliance_alert : ' '
31
- - license_key : mpl-2.0
32
- label : Restricted License
33
- compliance_alert : warning
34
30
- license_key : gpl-3.0
35
31
label : Prohibited License
36
32
compliance_alert : error
37
33
38
- - In the above policies file, licenses are referenced by the ``license_key ``,
39
- such as mit and gpl-3.0, which represents the ScanCode license key to match
40
- against detected licenses in the scan results.
41
- - A policy is defined with a ``label `` and a ``compliance_alert ``.
42
- The labels can be customized to your preferred wording.
43
- - The ``compliance_alert `` accepts 3 values:
44
-
45
- - ``'' `` (empty string)
46
- - ``warning ``
47
- - ``error ``
48
-
49
- Policies File Location
50
- ----------------------
51
-
52
- By default, ScanCode.io will look for a ``policies.yml `` file at the root of its
53
- app codebase.
54
-
55
- Alternatively, you can configure the location of policies files using the
56
- dedicated :ref: `scancodeio_settings_policies_file ` setting in your ``.env `` file.
57
-
58
- .. tip ::
59
- Check out our :ref: `scancodeio_settings ` section for a comprehensive list of
60
- settings including policies file setting.
61
-
62
- How Does The Compliance Alert Work?
63
- -----------------------------------
64
-
65
- The compliance system works by following a ``Precedence of Policies `` principal
66
- allowing the highest precedence policy to be applied in case of resources or
67
- packages with complex license expressions:
68
-
69
- - **error > warning > missing > '' (empty string) **
70
-
71
- This principal means a given resource with ``error AND warning AND '' ``
72
- license expression would have an overall compliance alert of ``error ``.
73
-
74
- .. warning ::
75
- The ``missing `` compliance alert value is applied for licenses not present in the
76
- policies file.
77
-
78
- Example Output
79
- --------------
80
-
81
- Create a ``policies.yml `` file in the root directory of your ScanCode.io codebase, with
82
- the following content:
83
-
84
- .. code-block :: yaml
85
-
86
- license_policies :
87
- - license_key : mit
88
- label : Approved License
89
- compliance_alert : ' '
90
- - license_key : gpl-3.0
91
- label : Prohibited License
92
- compliance_alert : error
93
-
94
- Run the following command to create a project and run the ``scan_codebase `` pipeline:
34
+ Run the following command to create a project and run the ``scan_codebase `` pipeline
35
+ (make sure to use the proper path for the policies.yml file):
95
36
96
37
.. code-block :: bash
97
38
98
39
$ scanpipe create-project cuckoo-filter-with-policies \
99
40
--input-url https://files.pythonhosted.org/packages/75/fc/f5b2e466d763dcc381d5127b73ffc265e8cdaf39ddafa422b7896e625432/cuckoo_filter-1.0.6.tar.gz \
41
+ --input-file policies.yml \
100
42
--pipeline scan_codebase \
101
43
--execute
102
44
103
45
Generate results:
104
46
105
47
.. code-block :: bash
106
48
107
- $ scanpipe output --project cuckoo-filter-with-policies
49
+ $ scanpipe output --print -- project cuckoo-filter-with-policies
108
50
109
51
The computed compliance alerts are now included in the results, available for each
110
- detected licenses , and computed at the codebase resource level, for example:
52
+ detected license , and computed at the codebase resource level, for example:
111
53
112
54
.. code-block :: json
113
55
@@ -123,38 +65,46 @@ detected licenses, and computed at the codebase resource level, for example:
123
65
"label" : " Recommended License" ,
124
66
"compliance_alert" : " "
125
67
},
126
- }
68
+ },
127
69
{
128
70
"key" : " gpl-3.0" ,
129
71
"name" : " GNU General Public License 3.0" ,
130
72
"policy" : {
131
73
"label" : " Prohibited License" ,
132
74
"compliance_alert" : " error"
133
- },
75
+ }
76
+ }
134
77
],
135
78
"license_expressions" : [
136
- " mit OR gpl-3.0" ,
79
+ " mit OR gpl-3.0"
137
80
],
138
81
"status" : " scanned" ,
139
82
"name" : " README" ,
140
83
"[...]" : " [...]"
141
84
}
142
85
143
- Web UI
144
- ------
86
+ Run the `` check-compliance `` command
87
+ ------------------------------------
145
88
146
- Compliance alerts are visible directly in the Web user interface through the following:
89
+ Run the ``check-compliance `` command to get a listing of the compliance alerts detected
90
+ in the project:
147
91
148
- * A summary panel in the project detail view:
149
-
150
- .. image:: images/tutorial-policies-compliance-alerts-panel.png
92
+ .. code-block :: bash
151
93
152
- * A dedicated column within the Packages and Resources list tables:
94
+ $ scanpipe check-compliance --project cuckoo-filter-with-policies --verbosity 2
153
95
154
- .. image :: images/tutorial-policies-compliance-alerts-column.png
96
+ .. code-block :: bash
155
97
156
- REST API
157
- --------
98
+ 4 compliance issues detected on this project.
99
+ [packages]
100
+ > ERROR: 3
101
+ pkg:pypi/cuckoo-filter@.
102
+ pkg:pypi/cuckoo-filter@1.0.6
103
+ pkg:pypi/cuckoo-filter@1.0.6
104
+ [resources]
105
+ > ERROR: 1
106
+ cuckoo_filter-1.0.6.tar.gz-extract/cuckoo_filter-1.0.6/README.md
158
107
159
- For more details on retrieving compliance data via the REST API, refer to the
160
- :ref:`rest_api_compliance` section.
108
+ .. tip ::
109
+ In case of compliance alerts, the command returns a non-zero exit code which
110
+ may be useful to trigger a failure in an automated process.
0 commit comments