continuous-delivery-scripts 3.3.0__tar.gz → 3.4.1__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.1}/PKG-INFO +3 -3
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/_version.py +4 -4
- continuous_delivery_scripts-3.4.1/continuous_delivery_scripts/detect_secrets.py +93 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/plugins/golang.py +9 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/plugins/python.py +14 -1
- continuous_delivery_scripts-3.4.1/continuous_delivery_scripts/update_secrets_registry.py +105 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/utils/configuration.py +15 -3
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/utils/git_helpers.py +35 -6
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/utils/language_specifics_base.py +5 -1
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1/continuous_delivery_scripts.egg-info}/PKG-INFO +3 -3
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts.egg-info/SOURCES.txt +2 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts.egg-info/entry_points.txt +2 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts.egg-info/requires.txt +2 -2
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/setup.py +4 -3
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/LICENSE +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/MANIFEST.in +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/README.md +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/__init__.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/assert_news.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/create_news_file.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/generate_docs.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/generate_news.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/get_config.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/get_version.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/language_specifics.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/license_files.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/plugins/BASIC.MD +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/plugins/CI.MD +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/plugins/GITHUB_ACTIONS.MD +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/plugins/GOLAND.MD +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/plugins/NOOP.MD +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/plugins/PYTHON.MD +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/plugins/__init__.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/plugins/basic.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/plugins/ci.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/plugins/docker.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/plugins/github_actions.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/plugins/noop.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/report_third_party_ip.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/spdx_report/__init__.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/spdx_report/spdx_dependency.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/spdx_report/spdx_document.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/spdx_report/spdx_file.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/spdx_report/spdx_helpers.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/spdx_report/spdx_package.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/spdx_report/spdx_project.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/spdx_report/spdx_summary.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/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.1}/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.1}/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.1}/continuous_delivery_scripts/tag_and_release.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/utils/__init__.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/utils/aws_helpers.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/utils/definitions.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/utils/filesystem_helpers.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/utils/hash_helpers.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/utils/logging.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/utils/news_file.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/utils/noop/__init__.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/utils/noop/package_helpers.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/utils/package_helpers.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/utils/python/__init__.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/utils/python/package_helpers.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/utils/python/python_helpers.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/utils/string_helpers.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/utils/third_party_licences.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts/utils/versioning.py +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts.egg-info/dependency_links.txt +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/continuous_delivery_scripts.egg-info/top_level.txt +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/pyproject.toml +0 -0
- {continuous_delivery_scripts-3.3.0 → continuous_delivery_scripts-3.4.1}/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.1
|
|
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,15 +29,15 @@ 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
|
|
35
36
|
Requires-Dist: license-expression
|
|
36
37
|
Requires-Dist: wcmatch
|
|
37
38
|
Requires-Dist: jellyfish
|
|
38
|
-
Requires-Dist: jinja2
|
|
39
|
+
Requires-Dist: jinja2<4,>=3
|
|
39
40
|
Requires-Dist: dataclasses; python_version < "3.7"
|
|
40
|
-
Requires-Dist: markupsafe==2.0.1
|
|
41
41
|
Dynamic: author
|
|
42
42
|
Dynamic: author-email
|
|
43
43
|
Dynamic: classifier
|
|
@@ -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.1"
|
|
15
|
+
COMMIT = "3cb7eefdafb8306ca4750f371325574e1a2ec9c7"
|
|
16
16
|
MAJOR = 3
|
|
17
|
-
MINOR =
|
|
18
|
-
PATCH =
|
|
17
|
+
MINOR = 4
|
|
18
|
+
PATCH = 1
|
|
@@ -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)
|
|
@@ -194,7 +196,13 @@ class GitWrapper:
|
|
|
194
196
|
|
|
195
197
|
def fetch(self) -> None:
|
|
196
198
|
"""Fetches latest changes."""
|
|
197
|
-
|
|
199
|
+
try:
|
|
200
|
+
self.repo.git.fetch(all=True, tags=True, force=True)
|
|
201
|
+
except GitCommandError as e:
|
|
202
|
+
logger.info("failed fetching repository: %s" % e)
|
|
203
|
+
logger.info("Retrying a different way")
|
|
204
|
+
self.set_remote_url(self._git_url_ssh_to_https(self.get_remote_url()))
|
|
205
|
+
self.repo.git.fetch(all=True, tags=True, force=True)
|
|
198
206
|
|
|
199
207
|
def get_branch(self, branch_name: str) -> Any:
|
|
200
208
|
"""Gets a specific local branch.
|
|
@@ -235,6 +243,12 @@ class GitWrapper:
|
|
|
235
243
|
current_branch = self._get_branch_from_abbreviation("HEAD")
|
|
236
244
|
return current_branch
|
|
237
245
|
|
|
246
|
+
def list_tracked_files(self) -> List[str]:
|
|
247
|
+
"""List git-tracked files relative to the repository root."""
|
|
248
|
+
tracked_files = self.repo.git.ls_files("-z")
|
|
249
|
+
tracked_files = tracked_files if isinstance(tracked_files, str) else tracked_files.decode("utf-8")
|
|
250
|
+
return [path for path in tracked_files.split("\0") if path]
|
|
251
|
+
|
|
238
252
|
def _get_branch_from_advanced_feature(self) -> Any:
|
|
239
253
|
if version.parse(self.git_version()) >= version.parse("2.22"):
|
|
240
254
|
current_branch = self.repo.git.branch(show_current=True)
|
|
@@ -298,7 +312,10 @@ class GitWrapper:
|
|
|
298
312
|
current_branch = self.get_current_branch()
|
|
299
313
|
merge_base = self.repo.merge_base(branch, current_branch)
|
|
300
314
|
self.repo.index.merge_tree(current_branch, base=merge_base)
|
|
301
|
-
self.commit(
|
|
315
|
+
self.commit(
|
|
316
|
+
f"Merge from {str(branch)}",
|
|
317
|
+
parent_commits=(branch.commit, current_branch.commit),
|
|
318
|
+
)
|
|
302
319
|
|
|
303
320
|
def get_remote_url(self) -> str:
|
|
304
321
|
"""Gets the URL of the remote repository.
|
|
@@ -416,7 +433,11 @@ class GitWrapper:
|
|
|
416
433
|
return changes
|
|
417
434
|
|
|
418
435
|
def get_changes_list(
|
|
419
|
-
self,
|
|
436
|
+
self,
|
|
437
|
+
commit1: Any,
|
|
438
|
+
commit2: Any,
|
|
439
|
+
change_type: Optional[str] = None,
|
|
440
|
+
dir: Optional[str] = None,
|
|
420
441
|
) -> List[str]:
|
|
421
442
|
"""Gets change list.
|
|
422
443
|
|
|
@@ -459,7 +480,12 @@ class GitWrapper:
|
|
|
459
480
|
Pushes changes to the remote repository.
|
|
460
481
|
Pushes also relevant annotated tags when pushing branches out.
|
|
461
482
|
"""
|
|
462
|
-
self.repo.git.push(
|
|
483
|
+
self.repo.git.push(
|
|
484
|
+
"--follow-tags",
|
|
485
|
+
"--set-upstream",
|
|
486
|
+
self._get_remote(),
|
|
487
|
+
self.get_current_branch(),
|
|
488
|
+
)
|
|
463
489
|
|
|
464
490
|
def push_tag(self) -> None:
|
|
465
491
|
"""Pushes commits and tags.
|
|
@@ -797,4 +823,7 @@ class ProjectTempClone(GitTempClone):
|
|
|
797
823
|
system will try to identify the current branch in the repository which
|
|
798
824
|
will work in most cases but probably not on CI.
|
|
799
825
|
"""
|
|
800
|
-
super().__init__(
|
|
826
|
+
super().__init__(
|
|
827
|
+
desired_branch_name=desired_branch_name,
|
|
828
|
+
repository_to_clone=ProjectGitWrapper(),
|
|
829
|
+
)
|
|
@@ -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.1
|
|
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,15 +29,15 @@ 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
|
|
35
36
|
Requires-Dist: license-expression
|
|
36
37
|
Requires-Dist: wcmatch
|
|
37
38
|
Requires-Dist: jellyfish
|
|
38
|
-
Requires-Dist: jinja2
|
|
39
|
+
Requires-Dist: jinja2<4,>=3
|
|
39
40
|
Requires-Dist: dataclasses; python_version < "3.7"
|
|
40
|
-
Requires-Dist: markupsafe==2.0.1
|
|
41
41
|
Dynamic: author
|
|
42
42
|
Dynamic: author-email
|
|
43
43
|
Dynamic: classifier
|
|
@@ -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
|
|
@@ -8,14 +8,14 @@ semver~=2.13.0
|
|
|
8
8
|
python-dotenv
|
|
9
9
|
twine
|
|
10
10
|
boto3
|
|
11
|
+
detect-secrets[gibberish]==1.5.0
|
|
11
12
|
packaging
|
|
12
13
|
licenseheaders<0.8.9
|
|
13
14
|
spdx-tools==0.6.1
|
|
14
15
|
license-expression
|
|
15
16
|
wcmatch
|
|
16
17
|
jellyfish
|
|
17
|
-
jinja2
|
|
18
|
-
markupsafe==2.0.1
|
|
18
|
+
jinja2<4,>=3
|
|
19
19
|
|
|
20
20
|
[:python_version < "3.7"]
|
|
21
21
|
dataclasses
|
|
@@ -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,16 +67,15 @@ 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",
|
|
71
74
|
"license-expression",
|
|
72
75
|
"wcmatch",
|
|
73
76
|
"jellyfish",
|
|
74
|
-
"jinja2
|
|
77
|
+
"jinja2>=3,<4",
|
|
75
78
|
"dataclasses; python_version<'3.7'",
|
|
76
|
-
# FIXME fixing markupsafe to solve https://github.com/pallets/markupsafe/issues/284 until jinja is upgraded
|
|
77
|
-
"markupsafe==2.0.1",
|
|
78
79
|
],
|
|
79
80
|
license="Apache 2.0",
|
|
80
81
|
long_description_content_type="text/markdown",
|
|
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
|