continuous-delivery-scripts 3.3.0__tar.gz → 3.4.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.
- {continuous_delivery_scripts-3.3.0/continuous_delivery_scripts.egg-info → continuous_delivery_scripts-3.4.0}/PKG-INFO +2 -1
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/_version.py +3 -3
- continuous_delivery_scripts-3.4.0/continuous_delivery_scripts/detect_secrets.py +93 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/plugins/golang.py +9 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/plugins/python.py +14 -1
- continuous_delivery_scripts-3.4.0/continuous_delivery_scripts/update_secrets_registry.py +105 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/utils/configuration.py +15 -3
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/utils/git_helpers.py +28 -5
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/utils/language_specifics_base.py +5 -1
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0/continuous_delivery_scripts.egg-info}/PKG-INFO +2 -1
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts.egg-info/SOURCES.txt +2 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts.egg-info/entry_points.txt +2 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts.egg-info/requires.txt +1 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/setup.py +3 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/LICENSE +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/MANIFEST.in +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/README.md +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/__init__.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/assert_news.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/create_news_file.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/generate_docs.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/generate_news.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/get_config.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/get_version.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/language_specifics.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/license_files.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/plugins/BASIC.MD +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/plugins/CI.MD +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/plugins/GITHUB_ACTIONS.MD +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/plugins/GOLAND.MD +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/plugins/NOOP.MD +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/plugins/PYTHON.MD +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/plugins/__init__.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/plugins/basic.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/plugins/ci.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/plugins/docker.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/plugins/github_actions.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/plugins/noop.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/report_third_party_ip.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/spdx_report/__init__.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/spdx_report/spdx_dependency.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/spdx_report/spdx_document.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/spdx_report/spdx_file.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/spdx_report/spdx_helpers.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/spdx_report/spdx_package.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/spdx_report/spdx_project.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/spdx_report/spdx_summary.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/spdx_report/templates/third_party_IP_report.csv.jinja2 +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/spdx_report/templates/third_party_IP_report.html.jinja2 +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/spdx_report/templates/third_party_IP_report.txt.jinja2 +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/tag_and_release.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/utils/__init__.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/utils/aws_helpers.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/utils/definitions.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/utils/filesystem_helpers.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/utils/hash_helpers.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/utils/logging.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/utils/news_file.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/utils/noop/__init__.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/utils/noop/package_helpers.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/utils/package_helpers.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/utils/python/__init__.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/utils/python/package_helpers.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/utils/python/python_helpers.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/utils/string_helpers.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/utils/third_party_licences.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts/utils/versioning.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts.egg-info/dependency_links.txt +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/continuous_delivery_scripts.egg-info/top_level.txt +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/pyproject.toml +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: continuous-delivery-scripts
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.4.0
|
|
4
4
|
Summary: Continuous Delivery scripts to increase automation
|
|
5
5
|
Home-page: https://github.com/ARMmbed/continuous-delivery-scripts
|
|
6
6
|
Author: CMSIS team
|
|
@@ -29,6 +29,7 @@ Requires-Dist: semver~=2.13.0
|
|
|
29
29
|
Requires-Dist: python-dotenv
|
|
30
30
|
Requires-Dist: twine
|
|
31
31
|
Requires-Dist: boto3
|
|
32
|
+
Requires-Dist: detect-secrets[gibberish]==1.5.0
|
|
32
33
|
Requires-Dist: packaging
|
|
33
34
|
Requires-Dist: licenseheaders<0.8.9
|
|
34
35
|
Requires-Dist: spdx-tools==0.6.1
|
|
@@ -11,8 +11,8 @@ References
|
|
|
11
11
|
This file is autogenerated, do not modify by hand.
|
|
12
12
|
"""
|
|
13
13
|
|
|
14
|
-
__version__ = "3.
|
|
15
|
-
COMMIT = "
|
|
14
|
+
__version__ = "3.4.0"
|
|
15
|
+
COMMIT = "593860a336acbead96e80e1a5c55aee240dbf97e"
|
|
16
16
|
MAJOR = 3
|
|
17
|
-
MINOR =
|
|
17
|
+
MINOR = 4
|
|
18
18
|
PATCH = 0
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved.
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
#
|
|
5
|
+
"""Check tracked files against the project's recorded secret registry."""
|
|
6
|
+
|
|
7
|
+
import argparse
|
|
8
|
+
import logging
|
|
9
|
+
import subprocess
|
|
10
|
+
import sys
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from typing import List, Optional
|
|
13
|
+
|
|
14
|
+
from continuous_delivery_scripts.update_secrets_registry import (
|
|
15
|
+
_determine_exclude_files,
|
|
16
|
+
_get_secrets_baseline_file,
|
|
17
|
+
_get_secrets_baseline_filename,
|
|
18
|
+
)
|
|
19
|
+
from continuous_delivery_scripts.utils.git_helpers import ProjectGitWrapper
|
|
20
|
+
from continuous_delivery_scripts.utils.logging import log_exception, set_log_level
|
|
21
|
+
|
|
22
|
+
logger = logging.getLogger(__name__)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _generate_detect_secrets_hook_command_list(
|
|
26
|
+
baseline_file: Path, exclude_files: List[str], tracked_files: List[str]
|
|
27
|
+
) -> List[str]:
|
|
28
|
+
command = ["detect-secrets-hook", "--baseline", str(baseline_file)]
|
|
29
|
+
for exclude_file in exclude_files:
|
|
30
|
+
command.extend(["--exclude-files", exclude_file])
|
|
31
|
+
command.extend(tracked_files)
|
|
32
|
+
return command
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _filter_tracked_files(tracked_files: List[str], project_root: Path, registry_file: Path) -> List[str]:
|
|
36
|
+
"""Remove the registry file from tracked files to avoid scanning recorded accepted findings."""
|
|
37
|
+
try:
|
|
38
|
+
registry_relative_path = registry_file.relative_to(project_root).as_posix()
|
|
39
|
+
except ValueError:
|
|
40
|
+
return tracked_files
|
|
41
|
+
return [path for path in tracked_files if path != registry_relative_path]
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def detect_secrets(baseline_file: Optional[Path] = None) -> None:
|
|
45
|
+
"""Check tracked files so new secrets are not introduced."""
|
|
46
|
+
git = ProjectGitWrapper()
|
|
47
|
+
project_root = Path(str(git.root))
|
|
48
|
+
resolved_baseline = _get_secrets_baseline_file(baseline_file)
|
|
49
|
+
tracked_files = _filter_tracked_files(git.list_tracked_files(), project_root, resolved_baseline)
|
|
50
|
+
if not tracked_files:
|
|
51
|
+
logger.info("No tracked files found for detect-secrets.")
|
|
52
|
+
return
|
|
53
|
+
subprocess.check_call(
|
|
54
|
+
_generate_detect_secrets_hook_command_list(resolved_baseline, _determine_exclude_files(), tracked_files),
|
|
55
|
+
cwd=str(project_root),
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def main() -> int:
|
|
60
|
+
"""Script CLI."""
|
|
61
|
+
parser = argparse.ArgumentParser(
|
|
62
|
+
description=(
|
|
63
|
+
"Check tracked files against the recorded secret registry so new secrets are not committed. "
|
|
64
|
+
"This uses Yelp detect-secrets (https://github.com/Yelp/detect-secrets)."
|
|
65
|
+
)
|
|
66
|
+
)
|
|
67
|
+
parser.add_argument(
|
|
68
|
+
"-r",
|
|
69
|
+
"--registry-file",
|
|
70
|
+
default=Path(_get_secrets_baseline_filename()),
|
|
71
|
+
help="Secret registry file to use.",
|
|
72
|
+
type=Path,
|
|
73
|
+
)
|
|
74
|
+
parser.add_argument(
|
|
75
|
+
"-v",
|
|
76
|
+
"--verbose",
|
|
77
|
+
action="count",
|
|
78
|
+
default=0,
|
|
79
|
+
help="Verbosity, by default errors are reported.",
|
|
80
|
+
)
|
|
81
|
+
args = parser.parse_args()
|
|
82
|
+
set_log_level(args.verbose)
|
|
83
|
+
|
|
84
|
+
try:
|
|
85
|
+
detect_secrets(args.registry_file)
|
|
86
|
+
return 0
|
|
87
|
+
except Exception as e:
|
|
88
|
+
log_exception(logger, e)
|
|
89
|
+
return 1
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
if __name__ == "__main__":
|
|
93
|
+
sys.exit(main())
|
|
@@ -203,6 +203,15 @@ class Go(BaseLanguage):
|
|
|
203
203
|
"""States whether project metadata can be retrieved."""
|
|
204
204
|
return False
|
|
205
205
|
|
|
206
|
+
def get_secret_registry_exclude_files(self) -> List[str]:
|
|
207
|
+
"""Gets additional detect-secrets exclude patterns for Go projects."""
|
|
208
|
+
return [
|
|
209
|
+
r".*go\.sum$",
|
|
210
|
+
r"^\.circleci[\\/].*",
|
|
211
|
+
r"^workflows/.*",
|
|
212
|
+
r"^\.github[\\/]workflows[\\/].*",
|
|
213
|
+
]
|
|
214
|
+
|
|
206
215
|
def get_current_spdx_project(self) -> Optional["SpdxProject"]:
|
|
207
216
|
"""Gets current SPDX description."""
|
|
208
217
|
# TODO
|
|
@@ -154,7 +154,7 @@ class Python(BaseLanguage):
|
|
|
154
154
|
|
|
155
155
|
def get_related_language(self) -> str:
|
|
156
156
|
"""Gets related language."""
|
|
157
|
-
return get_language_from_file_name(__file__)
|
|
157
|
+
return str(get_language_from_file_name(__file__))
|
|
158
158
|
|
|
159
159
|
def package_software(self, mode: CommitType, version: str) -> None:
|
|
160
160
|
"""Packages the software into a wheel."""
|
|
@@ -189,6 +189,19 @@ class Python(BaseLanguage):
|
|
|
189
189
|
# (SetuptoolsDeprecationWarning: License classifiers are deprecated)
|
|
190
190
|
return False
|
|
191
191
|
|
|
192
|
+
def get_secret_registry_exclude_files(self) -> List[str]:
|
|
193
|
+
"""Gets additional detect-secrets exclude patterns for Python projects."""
|
|
194
|
+
return [
|
|
195
|
+
r".*Pipfile\.lock$",
|
|
196
|
+
r".*poetry\.lock$",
|
|
197
|
+
r".*uv\.lock$",
|
|
198
|
+
r".*pdm\.lock$",
|
|
199
|
+
r".*version\.py$",
|
|
200
|
+
r"^\.circleci[\\/].*",
|
|
201
|
+
r"^workflows/.*",
|
|
202
|
+
r"^\.github[\\/]workflows[\\/].*",
|
|
203
|
+
]
|
|
204
|
+
|
|
192
205
|
def should_include_spdx_in_package(self) -> bool:
|
|
193
206
|
"""States whether the SPDX documents should be included in the package."""
|
|
194
207
|
# FIXME Comment out SPDX package as no longer working
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved.
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
#
|
|
5
|
+
"""Record the project's accepted secret registry using detect-secrets."""
|
|
6
|
+
|
|
7
|
+
import argparse
|
|
8
|
+
import logging
|
|
9
|
+
import re
|
|
10
|
+
import subprocess
|
|
11
|
+
import sys
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from typing import List, Optional
|
|
14
|
+
|
|
15
|
+
from continuous_delivery_scripts.language_specifics import get_language_specifics
|
|
16
|
+
from continuous_delivery_scripts.utils.configuration import (
|
|
17
|
+
configuration,
|
|
18
|
+
ConfigurationVariable,
|
|
19
|
+
)
|
|
20
|
+
from continuous_delivery_scripts.utils.logging import log_exception, set_log_level
|
|
21
|
+
|
|
22
|
+
logger = logging.getLogger(__name__)
|
|
23
|
+
|
|
24
|
+
GENERIC_SECRET_REGISTRY_EXCLUDE_FILES = [
|
|
25
|
+
r".*\.html$",
|
|
26
|
+
r".*\.properties$",
|
|
27
|
+
r".*ci\.yml$",
|
|
28
|
+
r"^\.git[\\/]",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _get_secrets_baseline_filename() -> str:
|
|
33
|
+
return str(configuration.get_value(ConfigurationVariable.SECRETS_BASELINE_FILENAME))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _get_secrets_baseline_file(output_file: Optional[Path] = None) -> Path:
|
|
37
|
+
project_root = Path(str(configuration.get_value(ConfigurationVariable.PROJECT_ROOT)))
|
|
38
|
+
baseline_file = output_file or Path(_get_secrets_baseline_filename())
|
|
39
|
+
return baseline_file if baseline_file.is_absolute() else project_root.joinpath(baseline_file)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _generate_detect_secrets_command_list(exclude_files: List[str]) -> List[str]:
|
|
43
|
+
command = ["detect-secrets", "scan", "--all-files"]
|
|
44
|
+
for exclude_file in exclude_files:
|
|
45
|
+
command.extend(["--exclude-files", exclude_file])
|
|
46
|
+
return command
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _determine_exclude_files() -> List[str]:
|
|
50
|
+
exclude_files = list(GENERIC_SECRET_REGISTRY_EXCLUDE_FILES)
|
|
51
|
+
baseline_file_pattern = re.escape(_get_secrets_baseline_filename()).replace(r"\\", r"[\\/]")
|
|
52
|
+
exclude_files.append(rf"^{baseline_file_pattern}$")
|
|
53
|
+
exclude_files.extend(get_language_specifics().get_secret_registry_exclude_files())
|
|
54
|
+
return list(dict.fromkeys(exclude_files))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def update_secrets_registry(output_file: Optional[Path] = None) -> Path:
|
|
58
|
+
"""Record the project's accepted secret registry for detect-secrets."""
|
|
59
|
+
project_root = Path(str(configuration.get_value(ConfigurationVariable.PROJECT_ROOT)))
|
|
60
|
+
baseline_file = _get_secrets_baseline_file(output_file)
|
|
61
|
+
logger.info("Updating secrets baseline at [%s].", baseline_file)
|
|
62
|
+
baseline_contents = subprocess.check_output(
|
|
63
|
+
_generate_detect_secrets_command_list(_determine_exclude_files()),
|
|
64
|
+
cwd=str(project_root),
|
|
65
|
+
encoding="utf8",
|
|
66
|
+
)
|
|
67
|
+
baseline_file.write_text(baseline_contents, encoding="utf8")
|
|
68
|
+
return baseline_file
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def main() -> int:
|
|
72
|
+
"""Script CLI."""
|
|
73
|
+
parser = argparse.ArgumentParser(
|
|
74
|
+
description=(
|
|
75
|
+
"Record the project's accepted secret registry so allowed findings are not flagged again. "
|
|
76
|
+
"This uses Yelp detect-secrets (https://github.com/Yelp/detect-secrets)."
|
|
77
|
+
)
|
|
78
|
+
)
|
|
79
|
+
parser.add_argument(
|
|
80
|
+
"-r",
|
|
81
|
+
"--registry-file",
|
|
82
|
+
default=_get_secrets_baseline_filename(),
|
|
83
|
+
help="Secret registry file to generate.",
|
|
84
|
+
type=Path,
|
|
85
|
+
)
|
|
86
|
+
parser.add_argument(
|
|
87
|
+
"-v",
|
|
88
|
+
"--verbose",
|
|
89
|
+
action="count",
|
|
90
|
+
default=0,
|
|
91
|
+
help="Verbosity, by default errors are reported.",
|
|
92
|
+
)
|
|
93
|
+
args = parser.parse_args()
|
|
94
|
+
set_log_level(args.verbose)
|
|
95
|
+
|
|
96
|
+
try:
|
|
97
|
+
update_secrets_registry(args.registry_file)
|
|
98
|
+
return 0
|
|
99
|
+
except Exception as e:
|
|
100
|
+
log_exception(logger, e)
|
|
101
|
+
return 1
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
if __name__ == "__main__":
|
|
105
|
+
sys.exit(main())
|
|
@@ -91,6 +91,8 @@ class ConfigurationVariable(enum.Enum):
|
|
|
91
91
|
"""States whether the release should be tagged with `latest`"""
|
|
92
92
|
TAG_VERSION_SHORTCUTS = 36
|
|
93
93
|
"""States whether the release should be tagged with shortcuts i.e. major, major+minor"""
|
|
94
|
+
SECRETS_BASELINE_FILENAME = 37
|
|
95
|
+
"""Filename for the detect-secrets baseline."""
|
|
94
96
|
|
|
95
97
|
@staticmethod
|
|
96
98
|
def choices() -> List[str]:
|
|
@@ -196,10 +198,20 @@ class StaticConfig(GenericConfig):
|
|
|
196
198
|
AUTOGENERATE_NEWS_FILE_ON_DEPENDENCY_UPDATE = True
|
|
197
199
|
TAG_LATEST = False
|
|
198
200
|
TAG_VERSION_SHORTCUTS = False
|
|
201
|
+
SECRETS_BASELINE_FILENAME = ".secrets.baseline"
|
|
199
202
|
DEPENDENCY_UPDATE_NEWS_MESSAGE = "Dependency upgrade: {message}"
|
|
200
203
|
DEPENDENCY_UPDATE_NEWS_TYPE = NewsType.bugfix
|
|
201
204
|
DEPENDENCY_UPDATE_BRANCH_PATTERN = r"^\s*[Dd]ependabot\/.+\/(?P<DEPENDENCY>.+)"
|
|
202
|
-
ACCEPTED_THIRD_PARTY_LICENCES = [
|
|
205
|
+
ACCEPTED_THIRD_PARTY_LICENCES = [
|
|
206
|
+
"Apache-2.0",
|
|
207
|
+
"BSD*",
|
|
208
|
+
"CC-BY-*",
|
|
209
|
+
"JSON",
|
|
210
|
+
"MIT",
|
|
211
|
+
"Python-2.0",
|
|
212
|
+
"PSF-2.0",
|
|
213
|
+
"MPL-2.0",
|
|
214
|
+
]
|
|
203
215
|
PACKAGES_WITH_CHECKED_LICENCE: List[str] = []
|
|
204
216
|
|
|
205
217
|
def _fetch_value(self, key: str) -> Any:
|
|
@@ -277,7 +289,7 @@ class FileConfig(GenericConfig):
|
|
|
277
289
|
@staticmethod
|
|
278
290
|
def _look_for_config_file_walking_up_tree() -> Optional[str]:
|
|
279
291
|
try:
|
|
280
|
-
return find_file_in_tree(FileConfig.CONFIG_FILE_NAME, top=True)
|
|
292
|
+
return str(find_file_in_tree(FileConfig.CONFIG_FILE_NAME, top=True))
|
|
281
293
|
except FileNotFoundError as e:
|
|
282
294
|
logger.warning(e)
|
|
283
295
|
return None
|
|
@@ -287,7 +299,7 @@ class FileConfig(GenericConfig):
|
|
|
287
299
|
if file_path and os.path.exists(file_path):
|
|
288
300
|
return file_path
|
|
289
301
|
try:
|
|
290
|
-
return find_file_in_tree(FileConfig.CONFIG_FILE_NAME)
|
|
302
|
+
return str(find_file_in_tree(FileConfig.CONFIG_FILE_NAME))
|
|
291
303
|
except FileNotFoundError:
|
|
292
304
|
return FileConfig._look_for_config_file_walking_up_tree()
|
|
293
305
|
|
|
@@ -61,7 +61,9 @@ class GitWrapper:
|
|
|
61
61
|
"""
|
|
62
62
|
try:
|
|
63
63
|
git_clone = self.repo.clone_from(
|
|
64
|
-
url=self.get_remote_url(),
|
|
64
|
+
url=self.get_remote_url(),
|
|
65
|
+
to_path=str(path),
|
|
66
|
+
multi_options=["--recurse-submodules"],
|
|
65
67
|
)
|
|
66
68
|
except GitCommandError as e:
|
|
67
69
|
logger.info("failed cloning repository: %s" % e)
|
|
@@ -235,6 +237,12 @@ class GitWrapper:
|
|
|
235
237
|
current_branch = self._get_branch_from_abbreviation("HEAD")
|
|
236
238
|
return current_branch
|
|
237
239
|
|
|
240
|
+
def list_tracked_files(self) -> List[str]:
|
|
241
|
+
"""List git-tracked files relative to the repository root."""
|
|
242
|
+
tracked_files = self.repo.git.ls_files("-z")
|
|
243
|
+
tracked_files = tracked_files if isinstance(tracked_files, str) else tracked_files.decode("utf-8")
|
|
244
|
+
return [path for path in tracked_files.split("\0") if path]
|
|
245
|
+
|
|
238
246
|
def _get_branch_from_advanced_feature(self) -> Any:
|
|
239
247
|
if version.parse(self.git_version()) >= version.parse("2.22"):
|
|
240
248
|
current_branch = self.repo.git.branch(show_current=True)
|
|
@@ -298,7 +306,10 @@ class GitWrapper:
|
|
|
298
306
|
current_branch = self.get_current_branch()
|
|
299
307
|
merge_base = self.repo.merge_base(branch, current_branch)
|
|
300
308
|
self.repo.index.merge_tree(current_branch, base=merge_base)
|
|
301
|
-
self.commit(
|
|
309
|
+
self.commit(
|
|
310
|
+
f"Merge from {str(branch)}",
|
|
311
|
+
parent_commits=(branch.commit, current_branch.commit),
|
|
312
|
+
)
|
|
302
313
|
|
|
303
314
|
def get_remote_url(self) -> str:
|
|
304
315
|
"""Gets the URL of the remote repository.
|
|
@@ -416,7 +427,11 @@ class GitWrapper:
|
|
|
416
427
|
return changes
|
|
417
428
|
|
|
418
429
|
def get_changes_list(
|
|
419
|
-
self,
|
|
430
|
+
self,
|
|
431
|
+
commit1: Any,
|
|
432
|
+
commit2: Any,
|
|
433
|
+
change_type: Optional[str] = None,
|
|
434
|
+
dir: Optional[str] = None,
|
|
420
435
|
) -> List[str]:
|
|
421
436
|
"""Gets change list.
|
|
422
437
|
|
|
@@ -459,7 +474,12 @@ class GitWrapper:
|
|
|
459
474
|
Pushes changes to the remote repository.
|
|
460
475
|
Pushes also relevant annotated tags when pushing branches out.
|
|
461
476
|
"""
|
|
462
|
-
self.repo.git.push(
|
|
477
|
+
self.repo.git.push(
|
|
478
|
+
"--follow-tags",
|
|
479
|
+
"--set-upstream",
|
|
480
|
+
self._get_remote(),
|
|
481
|
+
self.get_current_branch(),
|
|
482
|
+
)
|
|
463
483
|
|
|
464
484
|
def push_tag(self) -> None:
|
|
465
485
|
"""Pushes commits and tags.
|
|
@@ -797,4 +817,7 @@ class ProjectTempClone(GitTempClone):
|
|
|
797
817
|
system will try to identify the current branch in the repository which
|
|
798
818
|
will work in most cases but probably not on CI.
|
|
799
819
|
"""
|
|
800
|
-
super().__init__(
|
|
820
|
+
super().__init__(
|
|
821
|
+
desired_branch_name=desired_branch_name,
|
|
822
|
+
repository_to_clone=ProjectGitWrapper(),
|
|
823
|
+
)
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import logging
|
|
8
8
|
from abc import ABC, abstractmethod
|
|
9
9
|
from pathlib import Path
|
|
10
|
-
from typing import TYPE_CHECKING, Optional, Dict
|
|
10
|
+
from typing import TYPE_CHECKING, Optional, Dict, List
|
|
11
11
|
|
|
12
12
|
from continuous_delivery_scripts.utils.configuration import (
|
|
13
13
|
configuration,
|
|
@@ -72,6 +72,10 @@ class BaseLanguage(ABC):
|
|
|
72
72
|
"""States whether project metadata can be retrieved."""
|
|
73
73
|
return False
|
|
74
74
|
|
|
75
|
+
def get_secret_registry_exclude_files(self) -> List[str]:
|
|
76
|
+
"""Gets additional detect-secrets exclude patterns for this plugin."""
|
|
77
|
+
return list()
|
|
78
|
+
|
|
75
79
|
def should_include_spdx_in_package(self) -> bool:
|
|
76
80
|
"""States whether the SPDX documents should be included in the package."""
|
|
77
81
|
return False
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: continuous-delivery-scripts
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.4.0
|
|
4
4
|
Summary: Continuous Delivery scripts to increase automation
|
|
5
5
|
Home-page: https://github.com/ARMmbed/continuous-delivery-scripts
|
|
6
6
|
Author: CMSIS team
|
|
@@ -29,6 +29,7 @@ Requires-Dist: semver~=2.13.0
|
|
|
29
29
|
Requires-Dist: python-dotenv
|
|
30
30
|
Requires-Dist: twine
|
|
31
31
|
Requires-Dist: boto3
|
|
32
|
+
Requires-Dist: detect-secrets[gibberish]==1.5.0
|
|
32
33
|
Requires-Dist: packaging
|
|
33
34
|
Requires-Dist: licenseheaders<0.8.9
|
|
34
35
|
Requires-Dist: spdx-tools==0.6.1
|
|
@@ -8,6 +8,7 @@ continuous_delivery_scripts/__init__.py
|
|
|
8
8
|
continuous_delivery_scripts/_version.py
|
|
9
9
|
continuous_delivery_scripts/assert_news.py
|
|
10
10
|
continuous_delivery_scripts/create_news_file.py
|
|
11
|
+
continuous_delivery_scripts/detect_secrets.py
|
|
11
12
|
continuous_delivery_scripts/generate_docs.py
|
|
12
13
|
continuous_delivery_scripts/generate_news.py
|
|
13
14
|
continuous_delivery_scripts/get_config.py
|
|
@@ -16,6 +17,7 @@ continuous_delivery_scripts/language_specifics.py
|
|
|
16
17
|
continuous_delivery_scripts/license_files.py
|
|
17
18
|
continuous_delivery_scripts/report_third_party_ip.py
|
|
18
19
|
continuous_delivery_scripts/tag_and_release.py
|
|
20
|
+
continuous_delivery_scripts/update_secrets_registry.py
|
|
19
21
|
continuous_delivery_scripts.egg-info/PKG-INFO
|
|
20
22
|
continuous_delivery_scripts.egg-info/SOURCES.txt
|
|
21
23
|
continuous_delivery_scripts.egg-info/dependency_links.txt
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
[console_scripts]
|
|
2
2
|
cd-assert-news = continuous_delivery_scripts.assert_news:main
|
|
3
3
|
cd-create-news-file = continuous_delivery_scripts.create_news_file:main
|
|
4
|
+
cd-detect-secrets = continuous_delivery_scripts.detect_secrets:main
|
|
4
5
|
cd-determine-version = continuous_delivery_scripts.get_version:main
|
|
5
6
|
cd-generate-docs = continuous_delivery_scripts.generate_docs:main
|
|
6
7
|
cd-generate-news = continuous_delivery_scripts.generate_news:main
|
|
7
8
|
cd-generate-spdx = continuous_delivery_scripts.report_third_party_ip:main
|
|
8
9
|
cd-get-config = continuous_delivery_scripts.get_config:main
|
|
9
10
|
cd-license-files = continuous_delivery_scripts.license_files:main
|
|
11
|
+
cd-record-secrets = continuous_delivery_scripts.update_secrets_registry:main
|
|
10
12
|
cd-tag-and-release = continuous_delivery_scripts.tag_and_release:main
|
|
@@ -48,6 +48,8 @@ setup(
|
|
|
48
48
|
f"cd-get-config={SOURCE_DIR}.get_config:main",
|
|
49
49
|
f"cd-license-files={SOURCE_DIR}.license_files:main",
|
|
50
50
|
f"cd-generate-spdx={SOURCE_DIR}.report_third_party_ip:main",
|
|
51
|
+
f"cd-detect-secrets={SOURCE_DIR}.detect_secrets:main",
|
|
52
|
+
f"cd-record-secrets={SOURCE_DIR}.update_secrets_registry:main",
|
|
51
53
|
]
|
|
52
54
|
},
|
|
53
55
|
keywords="Arm Tools CI CD Continuous Delivery Scripts Automation",
|
|
@@ -65,6 +67,7 @@ setup(
|
|
|
65
67
|
"python-dotenv",
|
|
66
68
|
"twine",
|
|
67
69
|
"boto3",
|
|
70
|
+
"detect-secrets[gibberish]==1.5.0",
|
|
68
71
|
"packaging",
|
|
69
72
|
"licenseheaders<0.8.9",
|
|
70
73
|
"spdx-tools==0.6.1",
|
|
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
|
|
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
|