Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
apertis-image-recipes
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
infrastructure
apertis-image-recipes
Commits
0602aea1
Commit
0602aea1
authored
2 years ago
by
Detlev Casanova
Committed by
Walter Lozano
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
scripts/generate_bom.py: Drop relaxed search
parent
ae40ff60
No related branches found
Branches containing commit
No related tags found
1 merge request
!530
generate_bom: Rework scanning to improve reliability
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/generate_bom.py
+4
-33
4 additions, 33 deletions
scripts/generate_bom.py
with
4 additions
and
33 deletions
scripts/generate_bom.py
+
4
−
33
View file @
0602aea1
...
...
@@ -158,9 +158,8 @@ class PathDepth():
class
BomGenerator
():
def
__init__
(
self
,
bom_dir
,
relaxed
,
dpkg_status
,
verbose
,
pretty
,
comments
,
copyright
,
copyright_limit
):
def
__init__
(
self
,
bom_dir
,
dpkg_status
,
verbose
,
pretty
,
comments
,
copyright
,
copyright_limit
):
self
.
bom_dir
=
bom_dir
self
.
relaxed
=
relaxed
self
.
dpkg_status
=
dpkg_status
self
.
verbose
=
verbose
self
.
pretty
=
pretty
...
...
@@ -202,25 +201,6 @@ class BomGenerator():
return
NO_COPYRIGHT_INFO_FOUND
# Get the license for file by searching a match with the last part
# of the report generated by FOSSolgy as we can't rely on the folder
# used to upload the source code
def
get_license_relaxed
(
self
,
copyright_info
,
f_src
):
for
p
in
copyright_info
.
all_files_paragraphs
():
for
f
in
p
.
files
:
if
f
.
endswith
(
f_src
):
return
self
.
get_license_str
(
p
)
return
NO_LICENSE_INFO_FOUND
def
get_copyright_relaxed
(
self
,
copyright_info
,
f_src
):
for
p
in
copyright_info
.
all_files_paragraphs
():
for
f
in
p
.
files
:
if
f
.
endswith
(
f_src
):
return
self
.
get_copyright_str
(
p
)
return
NO_COPYRIGHT_INFO_FOUND
def
get_copyright_file
(
self
,
filenames
):
if
COPYRIGHT_REPORT
in
filenames
:
return
COPYRIGHT_REPORT
...
...
@@ -300,17 +280,11 @@ class BomGenerator():
out_copyright
.
add
(
NO_COPYRIGHT_INFO_FOUND
)
def
scan_regular_unit
(
self
,
unit_file_path
,
copyright_info
,
out_licenses
,
out_copyright
):
if
not
self
.
relaxed
:
license
=
self
.
get_license
(
copyright_info
,
unit_file_path
)
else
:
license
=
self
.
get_license_relaxed
(
copyright_info
,
unit_file_path
)
license
=
self
.
get_license
(
copyright_info
,
unit_file_path
)
out_licenses
.
add
(
license
)
if
self
.
copyright
:
if
not
self
.
relaxed
:
copyright
=
self
.
get_copyright
(
copyright_info
,
unit_file_path
)
else
:
copyright
=
self
.
get_copyright_relaxed
(
copyright_info
,
unit_file_path
)
copyright
=
self
.
get_copyright
(
copyright_info
,
unit_file_path
)
out_copyright
.
add
(
copyright
)
def
scan_units
(
self
,
binary_name
,
package_copyright_files
,
units
):
...
...
@@ -456,8 +430,6 @@ class BomGenerator():
def
main
(
argv
):
global
RELAXED_SEARCH
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"
-c
"
,
"
--comments
"
,
action
=
'
store_true
'
,
help
=
"
include license comments
"
)
parser
.
add_argument
(
"
-C
"
,
"
--copyright
"
,
action
=
'
store_true
'
,
help
=
"
include copyright information
"
)
...
...
@@ -465,14 +437,13 @@ def main(argv):
help
=
"
limit maximum number of characters in copyright information
"
)
parser
.
add_argument
(
"
-d
"
,
"
--dir
"
,
default
=
DEFAULT_BOM_DIR
,
help
=
"
directory to search for information
"
)
parser
.
add_argument
(
"
-p
"
,
"
--pretty
"
,
action
=
'
store_true
'
,
help
=
"
indent the JSON output
"
)
parser
.
add_argument
(
"
-r
"
,
"
--relaxed
"
,
action
=
'
store_true
'
,
help
=
"
use relaxed search
"
)
parser
.
add_argument
(
"
-s
"
,
"
--dpkg-status
"
,
default
=
DEFAULT_DPKG_STATUS
,
help
=
"
dpkg status file
"
)
parser
.
add_argument
(
"
-v
"
,
"
--verbose
"
,
type
=
int
,
default
=
VERBOSE_IMAGE
,
help
=
"
verbose use in output 0: image, 1: package, 2: binary, 3: source
"
)
args
=
parser
.
parse_args
()
bom_generator
=
BomGenerator
(
args
.
dir
,
args
.
relaxed
,
args
.
dpkg_status
,
args
.
verbose
,
args
.
pretty
,
args
.
comments
,
bom_generator
=
BomGenerator
(
args
.
dir
,
args
.
dpkg_status
,
args
.
verbose
,
args
.
pretty
,
args
.
comments
,
args
.
copyright
,
args
.
copyright_limit
)
bom_generator
.
check_packages_copyright
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment