scanoss 1.36.0__tar.gz → 1.37.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {scanoss-1.36.0/src/scanoss.egg-info → scanoss-1.37.0}/PKG-INFO +1 -1
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/__init__.py +1 -1
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/cli.py +69 -1
- scanoss-1.37.0/src/scanoss/data/build_date.txt +1 -0
- scanoss-1.37.0/src/scanoss/delta.py +197 -0
- {scanoss-1.36.0 → scanoss-1.37.0/src/scanoss.egg-info}/PKG-INFO +1 -1
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss.egg-info/SOURCES.txt +1 -0
- scanoss-1.36.0/src/scanoss/data/build_date.txt +0 -1
- {scanoss-1.36.0 → scanoss-1.37.0}/LICENSE +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/PACKAGE.md +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/README.md +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/pyproject.toml +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/setup.cfg +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/protoc_gen_swagger/__init__.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/protoc_gen_swagger/options/__init__.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/protoc_gen_swagger/options/annotations_pb2.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/protoc_gen_swagger/options/annotations_pb2.pyi +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/protoc_gen_swagger/options/annotations_pb2_grpc.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/protoc_gen_swagger/options/openapiv2_pb2.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/protoc_gen_swagger/options/openapiv2_pb2.pyi +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/protoc_gen_swagger/options/openapiv2_pb2_grpc.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/__init__.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/common/__init__.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/common/v2/__init__.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/common/v2/scanoss_common_pb2.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/common/v2/scanoss_common_pb2_grpc.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/components/__init__.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/components/v2/__init__.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/components/v2/scanoss_components_pb2.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/components/v2/scanoss_components_pb2_grpc.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/cryptography/v2/scanoss_cryptography_pb2.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/cryptography/v2/scanoss_cryptography_pb2_grpc.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/dependencies/__init__.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/dependencies/v2/__init__.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/dependencies/v2/scanoss_dependencies_pb2.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/dependencies/v2/scanoss_dependencies_pb2_grpc.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/geoprovenance/__init__.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/geoprovenance/v2/__init__.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/geoprovenance/v2/scanoss_geoprovenance_pb2.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/geoprovenance/v2/scanoss_geoprovenance_pb2_grpc.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/licenses/__init__.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/licenses/v2/__init__.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/licenses/v2/scanoss_licenses_pb2.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/licenses/v2/scanoss_licenses_pb2_grpc.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/scanning/__init__.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/scanning/v2/__init__.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/scanning/v2/scanoss_scanning_pb2.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/scanning/v2/scanoss_scanning_pb2_grpc.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/semgrep/__init__.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/semgrep/v2/__init__.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/semgrep/v2/scanoss_semgrep_pb2.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/semgrep/v2/scanoss_semgrep_pb2_grpc.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/vulnerabilities/__init__.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/vulnerabilities/v2/__init__.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/vulnerabilities/v2/scanoss_vulnerabilities_pb2.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/vulnerabilities/v2/scanoss_vulnerabilities_pb2_grpc.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/components.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/constants.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/cryptography.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/csvoutput.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/cyclonedx.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/data/scanoss-settings-schema.json +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/data/spdx-exceptions.json +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/data/spdx-licenses.json +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/export/__init__.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/export/dependency_track.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/file_filters.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/filecount.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/inspection/__init__.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/inspection/dependency_track/project_violation.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/inspection/policy_check.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/inspection/raw/component_summary.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/inspection/raw/copyleft.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/inspection/raw/license_summary.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/inspection/raw/raw_base.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/inspection/raw/undeclared_component.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/inspection/utils/license_utils.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/results.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/scancodedeps.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/scanner.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/scanners/__init__.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/scanners/container_scanner.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/scanners/folder_hasher.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/scanners/scanner_config.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/scanners/scanner_hfh.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/scanoss_settings.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/scanossapi.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/scanossbase.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/scanossgrpc.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/scanpostprocessor.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/scantype.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/services/dependency_track_service.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/spdxlite.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/threadeddependencies.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/threadedscanning.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/utils/__init__.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/utils/abstract_presenter.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/utils/crc64.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/utils/file.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/utils/simhash.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/winnowing.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss.egg-info/dependency_links.txt +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss.egg-info/entry_points.txt +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss.egg-info/requires.txt +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss.egg-info/top_level.txt +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/tests/test_csv_output.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/tests/test_file_filters.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/tests/test_policy_inspect.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/tests/test_scan_post_processor.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/tests/test_spdxlite.py +0 -0
- {scanoss-1.36.0 → scanoss-1.37.0}/tests/test_winnowing.py +0 -0
|
@@ -33,6 +33,7 @@ from typing import List
|
|
|
33
33
|
import pypac
|
|
34
34
|
|
|
35
35
|
from scanoss.cryptography import Cryptography, create_cryptography_config_from_args
|
|
36
|
+
from scanoss.delta import Delta
|
|
36
37
|
from scanoss.export.dependency_track import DependencyTrackExporter
|
|
37
38
|
from scanoss.inspection.dependency_track.project_violation import (
|
|
38
39
|
DependencyTrackProjectViolationPolicyCheck,
|
|
@@ -919,6 +920,33 @@ def setup_args() -> None: # noqa: PLR0912, PLR0915
|
|
|
919
920
|
)
|
|
920
921
|
p_folder_hash.set_defaults(func=folder_hash)
|
|
921
922
|
|
|
923
|
+
# Sub-command: delta
|
|
924
|
+
p_delta = subparsers.add_parser(
|
|
925
|
+
'delta',
|
|
926
|
+
aliases=['dl'],
|
|
927
|
+
description=f'SCANOSS Delta commands: {__version__}',
|
|
928
|
+
help='Delta support commands',
|
|
929
|
+
)
|
|
930
|
+
|
|
931
|
+
delta_sub = p_delta.add_subparsers(
|
|
932
|
+
title='Delta Commands',
|
|
933
|
+
dest='subparsercmd',
|
|
934
|
+
description='Delta sub-commands',
|
|
935
|
+
help='Delta sub-commands'
|
|
936
|
+
)
|
|
937
|
+
|
|
938
|
+
# Delta Sub-command: copy
|
|
939
|
+
p_copy = delta_sub.add_parser(
|
|
940
|
+
'copy',
|
|
941
|
+
aliases=['cp'],
|
|
942
|
+
description=f'Copy file list into delta dir: {__version__}',
|
|
943
|
+
help='Copy the given list of files into a delta directory',
|
|
944
|
+
)
|
|
945
|
+
p_copy.add_argument('--input', '-i', type=str, required=True, help='Input file with diff list')
|
|
946
|
+
p_copy.add_argument('--folder', '-fd', type=str, help='Delta folder to copy into')
|
|
947
|
+
p_copy.add_argument('--root', '-rd', type=str, help='Root directory to place delta folder')
|
|
948
|
+
p_copy.set_defaults(func=delta_copy)
|
|
949
|
+
|
|
922
950
|
# Output options
|
|
923
951
|
for p in [
|
|
924
952
|
p_scan,
|
|
@@ -939,6 +967,7 @@ def setup_args() -> None: # noqa: PLR0912, PLR0915
|
|
|
939
967
|
p_crypto_hints,
|
|
940
968
|
p_crypto_versions_in_range,
|
|
941
969
|
c_licenses,
|
|
970
|
+
p_copy,
|
|
942
971
|
]:
|
|
943
972
|
p.add_argument('--output', '-o', type=str, help='Output result file name (optional - default stdout).')
|
|
944
973
|
|
|
@@ -1136,6 +1165,7 @@ def setup_args() -> None: # noqa: PLR0912, PLR0915
|
|
|
1136
1165
|
p_crypto_versions_in_range,
|
|
1137
1166
|
c_licenses,
|
|
1138
1167
|
e_dt,
|
|
1168
|
+
p_copy
|
|
1139
1169
|
]:
|
|
1140
1170
|
p.add_argument('--debug', '-d', action='store_true', help='Enable debug messages')
|
|
1141
1171
|
p.add_argument('--trace', '-t', action='store_true', help='Enable trace messages, including API posts')
|
|
@@ -1156,7 +1186,8 @@ def setup_args() -> None: # noqa: PLR0912, PLR0915
|
|
|
1156
1186
|
sys.exit(1)
|
|
1157
1187
|
elif (
|
|
1158
1188
|
args.subparser
|
|
1159
|
-
in ('utils', 'ut', 'component', 'comp', 'inspect', 'insp', 'ins',
|
|
1189
|
+
in ('utils', 'ut', 'component', 'comp', 'inspect', 'insp', 'ins',
|
|
1190
|
+
'crypto', 'cr', 'export', 'exp', 'delta', 'dl')
|
|
1160
1191
|
) and not args.subparsercmd:
|
|
1161
1192
|
parser.parse_args([args.subparser, '--help']) # Force utils helps to be displayed
|
|
1162
1193
|
sys.exit(1)
|
|
@@ -2603,6 +2634,43 @@ def initialise_empty_file(filename: str):
|
|
|
2603
2634
|
print_stderr(f'Error: Unable to create output file {filename}: {e}')
|
|
2604
2635
|
sys.exit(1)
|
|
2605
2636
|
|
|
2637
|
+
def delta_copy(parser, args):
|
|
2638
|
+
"""
|
|
2639
|
+
Handle delta copy command.
|
|
2640
|
+
|
|
2641
|
+
Copies files listed in an input file to a target directory while preserving
|
|
2642
|
+
their directory structure. Creates a unique delta directory if none is specified.
|
|
2643
|
+
|
|
2644
|
+
Parameters
|
|
2645
|
+
----------
|
|
2646
|
+
parser : ArgumentParser
|
|
2647
|
+
Command line parser object for help display
|
|
2648
|
+
args : Namespace
|
|
2649
|
+
Parsed command line arguments containing:
|
|
2650
|
+
- input: Path to file containing list of files to copy
|
|
2651
|
+
- folder: Optional target directory path
|
|
2652
|
+
- output: Optional output file path
|
|
2653
|
+
"""
|
|
2654
|
+
# Validate required input file parameter
|
|
2655
|
+
if args.input is None:
|
|
2656
|
+
print_stderr('ERROR: Input file is required for copying')
|
|
2657
|
+
parser.parse_args([args.subparser, args.subparsercmd, '-h'])
|
|
2658
|
+
sys.exit(1)
|
|
2659
|
+
# Initialise output file if specified
|
|
2660
|
+
if args.output:
|
|
2661
|
+
initialise_empty_file(args.output)
|
|
2662
|
+
try:
|
|
2663
|
+
# Create and configure delta copy command
|
|
2664
|
+
delta = Delta(debug=args.debug, trace=args.trace, quiet=args.quiet, filepath=args.input, folder=args.folder,
|
|
2665
|
+
output=args.output, root_dir=args.root)
|
|
2666
|
+
# Execute copy and exit with appropriate status code
|
|
2667
|
+
status, _ = delta.copy()
|
|
2668
|
+
sys.exit(status)
|
|
2669
|
+
except Exception as e:
|
|
2670
|
+
print_stderr(e)
|
|
2671
|
+
if args.debug:
|
|
2672
|
+
traceback.print_exc()
|
|
2673
|
+
sys.exit(1)
|
|
2606
2674
|
|
|
2607
2675
|
def main():
|
|
2608
2676
|
"""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
date: 20251017144212, utime: 1760712132
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"""
|
|
2
|
+
SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2025, SCANOSS
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
|
14
|
+
all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
THE SOFTWARE.
|
|
23
|
+
"""
|
|
24
|
+
import os
|
|
25
|
+
import shutil
|
|
26
|
+
import tempfile
|
|
27
|
+
from typing import Optional
|
|
28
|
+
|
|
29
|
+
from .scanossbase import ScanossBase
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class Delta(ScanossBase):
|
|
33
|
+
"""
|
|
34
|
+
Handle delta scan operations by copying files into a dedicated delta directory.
|
|
35
|
+
|
|
36
|
+
This class manages the creation of delta directories and copying of specified files
|
|
37
|
+
while preserving the directory structure. Files are read from an input file where each
|
|
38
|
+
line contains a file path to copy.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
def __init__( # noqa: PLR0913
|
|
42
|
+
self,
|
|
43
|
+
debug: bool = False,
|
|
44
|
+
trace: bool = False,
|
|
45
|
+
quiet: bool = False,
|
|
46
|
+
filepath: str = None,
|
|
47
|
+
folder: str = None,
|
|
48
|
+
output: str = None,
|
|
49
|
+
root_dir: str = None,
|
|
50
|
+
):
|
|
51
|
+
"""
|
|
52
|
+
Initialise the Delta instance.
|
|
53
|
+
|
|
54
|
+
:param debug: Enable debug logging.
|
|
55
|
+
:param trace: Enable trace logging.
|
|
56
|
+
:param quiet: Enable quiet mode (suppress non-essential output).
|
|
57
|
+
:param filepath: Path to an input file containing a list of files to copy.
|
|
58
|
+
:param folder: A target delta directory path (auto-generated if not provided).
|
|
59
|
+
:param output: Output file path for the delta directory location (stdout if not provided).
|
|
60
|
+
"""
|
|
61
|
+
super().__init__(debug, trace, quiet)
|
|
62
|
+
self.filepath = filepath
|
|
63
|
+
self.folder = folder
|
|
64
|
+
self.output = output
|
|
65
|
+
self.root_dir = root_dir if root_dir else '.'
|
|
66
|
+
|
|
67
|
+
def copy(self, input_file: str = None):
|
|
68
|
+
"""
|
|
69
|
+
Copy files listed in the input file to the delta directory.
|
|
70
|
+
|
|
71
|
+
Reads the input file line by line, where each line contains a file path.
|
|
72
|
+
Creates the delta directory if it doesn't exist, then copies each file
|
|
73
|
+
while preserving its directory structure.
|
|
74
|
+
|
|
75
|
+
:return: Tuple of (status_code, folder_path) where status_code is 0 for success,
|
|
76
|
+
1 for error, and folder_path is the delta directory path
|
|
77
|
+
"""
|
|
78
|
+
input_file = input_file if input_file else self.filepath
|
|
79
|
+
if not input_file:
|
|
80
|
+
self.print_stderr('ERROR: No input file specified')
|
|
81
|
+
return 1, ''
|
|
82
|
+
# Validate that an input file exists
|
|
83
|
+
if not os.path.isfile(input_file):
|
|
84
|
+
self.print_stderr(f'ERROR: Input file {input_file} does not exist or is not a file')
|
|
85
|
+
return 1, ''
|
|
86
|
+
# Load the input file and validate it contains valid file paths
|
|
87
|
+
files = self.load_input_file(input_file)
|
|
88
|
+
if files is None:
|
|
89
|
+
return 1, ''
|
|
90
|
+
# Create delta dir (folder)
|
|
91
|
+
delta_folder = self.create_delta_dir(self.folder, self.root_dir)
|
|
92
|
+
if not delta_folder:
|
|
93
|
+
return 1, ''
|
|
94
|
+
# Print delta folder location to output
|
|
95
|
+
self.print_to_file_or_stdout(delta_folder, self.output)
|
|
96
|
+
# Process each file and copy it to the delta dir
|
|
97
|
+
for source_file in files:
|
|
98
|
+
# Normalise the source path to handle ".." and redundant separators
|
|
99
|
+
normalised_source = os.path.normpath(source_file)
|
|
100
|
+
if '..' in normalised_source:
|
|
101
|
+
self.print_stderr(f'WARNING: Source path escapes root directory for {source_file}. Skipping.')
|
|
102
|
+
continue
|
|
103
|
+
# Resolve to the absolute path for source validation
|
|
104
|
+
abs_source = os.path.abspath(os.path.join(self.root_dir, normalised_source))
|
|
105
|
+
# Check if the source file exists and is a file
|
|
106
|
+
if not os.path.exists(abs_source) or not os.path.isfile(abs_source):
|
|
107
|
+
self.print_stderr(f'WARNING: File {source_file} does not exist or is not a file, skipping')
|
|
108
|
+
continue
|
|
109
|
+
# Use a normalised source for destination to prevent traversal
|
|
110
|
+
dest_path = os.path.normpath(os.path.join(self.root_dir, delta_folder, normalised_source.lstrip(os.sep)))
|
|
111
|
+
# Final safety check: ensure destination is within the delta folder
|
|
112
|
+
abs_dest = os.path.abspath(dest_path)
|
|
113
|
+
abs_folder = os.path.abspath(os.path.join(self.root_dir, delta_folder))
|
|
114
|
+
if not abs_dest.startswith(abs_folder + os.sep):
|
|
115
|
+
self.print_stderr(
|
|
116
|
+
f'WARNING: Destination path ({abs_dest}) escapes delta directory for {source_file}. Skipping.')
|
|
117
|
+
continue
|
|
118
|
+
# Create the destination directory if it doesn't exist and copy the file
|
|
119
|
+
try:
|
|
120
|
+
dest_dir = os.path.dirname(dest_path)
|
|
121
|
+
if dest_dir:
|
|
122
|
+
self.print_trace(f'Creating directory {dest_dir}...')
|
|
123
|
+
os.makedirs(dest_dir, exist_ok=True)
|
|
124
|
+
self.print_debug(f'Copying {source_file} to {dest_path} ...')
|
|
125
|
+
shutil.copy(abs_source, dest_path)
|
|
126
|
+
except (OSError, shutil.Error) as e:
|
|
127
|
+
self.print_stderr(f'ERROR: Failed to copy {source_file} to {dest_path}: {e}')
|
|
128
|
+
return 1, ''
|
|
129
|
+
return 0, delta_folder
|
|
130
|
+
|
|
131
|
+
def create_delta_dir(self, folder: str, root_dir: str = '.') -> str or None:
|
|
132
|
+
"""
|
|
133
|
+
Create the delta directory.
|
|
134
|
+
|
|
135
|
+
If no folder is specified, creates a unique temporary directory with
|
|
136
|
+
a 'delta-' prefix in the current directory. If a folder is specified,
|
|
137
|
+
validates that it doesn't already exist before creating it.
|
|
138
|
+
|
|
139
|
+
:param root_dir: Root directory to create the delta directory in (default: current directory)
|
|
140
|
+
:param folder: Optional target directory
|
|
141
|
+
:return: Path to the delta directory, or None if it already exists or creation fails
|
|
142
|
+
"""
|
|
143
|
+
if folder:
|
|
144
|
+
# Resolve a relative folder under root_dir so checks/creation apply to the right place
|
|
145
|
+
resolved = folder if os.path.isabs(folder) else os.path.join(root_dir, folder)
|
|
146
|
+
resolved = os.path.normpath(resolved)
|
|
147
|
+
# Validate the target directory doesn't already exist and create it
|
|
148
|
+
if os.path.exists(resolved):
|
|
149
|
+
self.print_stderr(f'ERROR: Folder {resolved} already exists.')
|
|
150
|
+
return None
|
|
151
|
+
else:
|
|
152
|
+
try:
|
|
153
|
+
self.print_debug(f'Creating delta directory {resolved}...')
|
|
154
|
+
os.makedirs(resolved)
|
|
155
|
+
except (OSError, IOError) as e:
|
|
156
|
+
self.print_stderr(f'ERROR: Failed to create directory {resolved}: {e}')
|
|
157
|
+
return None
|
|
158
|
+
else:
|
|
159
|
+
# Create a unique temporary directory in the given root directory
|
|
160
|
+
try:
|
|
161
|
+
self.print_debug(f'Creating temporary delta directory in {root_dir} ...')
|
|
162
|
+
folder = tempfile.mkdtemp(prefix="delta-", dir=root_dir)
|
|
163
|
+
if folder:
|
|
164
|
+
folder = os.path.relpath(folder, start=root_dir) # Get the relative path from root_dir
|
|
165
|
+
self.print_debug(f'Created temporary delta directory: {folder}')
|
|
166
|
+
except (OSError, IOError) as e:
|
|
167
|
+
self.print_stderr(f'ERROR: Failed to create temporary directory in {root_dir}: {e}')
|
|
168
|
+
return None
|
|
169
|
+
return folder
|
|
170
|
+
|
|
171
|
+
def load_input_file(self, input_file: str) -> Optional[list[str]]:
|
|
172
|
+
"""
|
|
173
|
+
Loads and parses the input file line by line. Each line in the input
|
|
174
|
+
file represents a source file path, which will be stripped of trailing
|
|
175
|
+
whitespace and appended to the resulting list if it is not empty.
|
|
176
|
+
|
|
177
|
+
:param input_file: The path to the input file to be read.
|
|
178
|
+
:type input_file: String
|
|
179
|
+
:return: A list of source file paths extracted from the input file,
|
|
180
|
+
or None if an error occurs or the file path is invalid.
|
|
181
|
+
:rtype: An array list[str] or None
|
|
182
|
+
"""
|
|
183
|
+
files = []
|
|
184
|
+
if input_file:
|
|
185
|
+
try:
|
|
186
|
+
with open(input_file, 'r', encoding='utf-8') as f:
|
|
187
|
+
for line in f:
|
|
188
|
+
source_file = line.rstrip()
|
|
189
|
+
if source_file:
|
|
190
|
+
# Save the file path without any leading separators
|
|
191
|
+
files.append(source_file.lstrip(os.sep))
|
|
192
|
+
# End of for loop
|
|
193
|
+
except (OSError, IOError) as e:
|
|
194
|
+
self.print_stderr(f'ERROR: Failed to read input file; {input_file}: {e}')
|
|
195
|
+
return None
|
|
196
|
+
self.print_debug(f'Loaded {len(files)} files from input file.')
|
|
197
|
+
return files
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
date: 20251013130805, utime: 1760360885
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/components/v2/scanoss_components_pb2_grpc.py
RENAMED
|
File without changes
|
{scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/cryptography/v2/scanoss_cryptography_pb2.py
RENAMED
|
File without changes
|
{scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/cryptography/v2/scanoss_cryptography_pb2_grpc.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/dependencies/v2/scanoss_dependencies_pb2.py
RENAMED
|
File without changes
|
{scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/dependencies/v2/scanoss_dependencies_pb2_grpc.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/geoprovenance/v2/scanoss_geoprovenance_pb2.py
RENAMED
|
File without changes
|
{scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/geoprovenance/v2/scanoss_geoprovenance_pb2_grpc.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/api/vulnerabilities/v2/scanoss_vulnerabilities_pb2.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{scanoss-1.36.0 → scanoss-1.37.0}/src/scanoss/inspection/dependency_track/project_violation.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|