ScriptCollection 4.2.136__py3-none-any.whl → 4.2.138__py3-none-any.whl
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.
- ScriptCollection/ScriptCollectionCore.py +1 -1
- ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py +51 -8
- {scriptcollection-4.2.136.dist-info → scriptcollection-4.2.138.dist-info}/METADATA +1 -1
- {scriptcollection-4.2.136.dist-info → scriptcollection-4.2.138.dist-info}/RECORD +7 -7
- {scriptcollection-4.2.136.dist-info → scriptcollection-4.2.138.dist-info}/WHEEL +0 -0
- {scriptcollection-4.2.136.dist-info → scriptcollection-4.2.138.dist-info}/entry_points.txt +0 -0
- {scriptcollection-4.2.136.dist-info → scriptcollection-4.2.138.dist-info}/top_level.txt +0 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import json
|
|
3
|
+
import re
|
|
4
|
+
import socket
|
|
3
5
|
from datetime import datetime, timedelta,timezone
|
|
4
6
|
import xmlschema
|
|
5
7
|
import yaml
|
|
@@ -277,23 +279,37 @@ class TFCPS_CodeUnit_BuildCodeUnits:
|
|
|
277
279
|
@GeneralUtilities.check_arguments
|
|
278
280
|
def search_for_secrets(self) -> None:
|
|
279
281
|
self.sc.log.log("Search for secrets...")
|
|
280
|
-
self.sc.run_program("ls","-la",self.repository,print_live_output=True)
|
|
281
|
-
self.sc.run_program("git","status",self.repository,print_live_output=True)
|
|
282
|
-
self.sc.run_program("cat",".betterleaks.toml",self.repository,print_live_output=True)
|
|
283
282
|
try:
|
|
284
283
|
image = self.tfcps_tools_general.oci_image_manager.get_registry_address_for_image_with_default_tag(self.repository, "Betterleaks")
|
|
285
284
|
except Exception:
|
|
286
285
|
image="ghcr.io/betterleaks/betterleaks:latest"
|
|
287
286
|
config_file = os.path.join(self.repository, ".betterleaks.toml")
|
|
288
|
-
|
|
287
|
+
running_in_container = os.path.exists("/.dockerenv") or self.sc.is_running_in_build_container()
|
|
288
|
+
if running_in_container:
|
|
289
|
+
# We run inside the build-container with the docker-socket forwarded to the host-daemon.
|
|
290
|
+
# A bind-mount of our in-container repository-path (e.g. "/__w/<repo>/<repo>" on a
|
|
291
|
+
# GitHub-runner or "/Workspace/Repository" when the pipeline is run locally) would be
|
|
292
|
+
# resolved by the host-daemon, where that path does not exist or points to unrelated
|
|
293
|
+
# data (for example test-service-volumes written there by other sibling-containers).
|
|
294
|
+
# The sibling betterleaks-container would then scan the wrong directory - without the
|
|
295
|
+
# repository-content and without ".betterleaks.toml", which causes false positives.
|
|
296
|
+
# Sharing our own volumes instead exposes the repository to betterleaks at the same path.
|
|
297
|
+
mount_arguments = ["--volumes-from", self.__get_own_container_id()]
|
|
298
|
+
repository_in_scan_container = self.repository
|
|
299
|
+
else:
|
|
300
|
+
# Running directly on the host: a normal bind-mount works because the path is resolved
|
|
301
|
+
# on the same filesystem the docker-daemon uses.
|
|
302
|
+
mount_arguments = ["-v", f"{self.repository}:/repo"]
|
|
303
|
+
repository_in_scan_container = "/repo"
|
|
304
|
+
scan_args = ["dir", repository_in_scan_container, "-v"]
|
|
289
305
|
if os.path.isfile(config_file):
|
|
290
306
|
# Pass the config explicitly instead of relying on auto-detection, because betterleaks
|
|
291
|
-
# silently falls back to the default ruleset
|
|
292
|
-
#
|
|
293
|
-
scan_args = scan_args + ["-c", "
|
|
307
|
+
# silently falls back to the default ruleset when it does not find the config at the
|
|
308
|
+
# scan-root, which results in false positives.
|
|
309
|
+
scan_args = scan_args + ["-c", f"{repository_in_scan_container}/.betterleaks.toml"]
|
|
294
310
|
else:
|
|
295
311
|
self.sc.log.log(f"No betterleaks-config found at '{config_file}'; scanning with default ruleset only.", LogLevel.Warning)
|
|
296
|
-
args = ["run", "--rm"
|
|
312
|
+
args = ["run", "--rm"] + mount_arguments + [image] + scan_args
|
|
297
313
|
result = self.sc.run_program_argsasarray("docker", args, throw_exception_if_exitcode_is_not_zero=False, print_live_output=self.sc.log.loglevel==LogLevel.Debug)
|
|
298
314
|
if result[0] != 0:
|
|
299
315
|
for line in GeneralUtilities.string_to_lines(result[1]):
|
|
@@ -302,6 +318,33 @@ class TFCPS_CodeUnit_BuildCodeUnits:
|
|
|
302
318
|
self.sc.log.log(line, LogLevel.Error)
|
|
303
319
|
raise ValueError(f"Found unignored secret findings (exit code {result[0]}). See {os.path.join(self.repository, '.betterleaks.toml')} to ignore known false positives.")
|
|
304
320
|
|
|
321
|
+
@GeneralUtilities.check_arguments
|
|
322
|
+
def __get_own_container_id(self) -> str:
|
|
323
|
+
# Determine the id of the container this process runs in so its volumes can be shared with
|
|
324
|
+
# sibling-containers via "docker run --volumes-from".
|
|
325
|
+
# In mountinfo the own container-id only appears reliably in the source-path of the
|
|
326
|
+
# "/etc/hostname"/"/etc/hosts"/"/etc/resolv.conf"-mounts (".../containers/<id>/..."). A plain
|
|
327
|
+
# 64-hex-match there would also hit overlay-layer-hashes (which are not containers), so the
|
|
328
|
+
# "containers/"-prefix must be matched explicitly.
|
|
329
|
+
try:
|
|
330
|
+
with open("/proc/self/mountinfo", "r", encoding="utf-8") as file_handle:
|
|
331
|
+
match = re.search(r"/containers/([0-9a-f]{64})/", file_handle.read())
|
|
332
|
+
if match is not None:
|
|
333
|
+
return match.group(1)
|
|
334
|
+
except Exception:
|
|
335
|
+
pass
|
|
336
|
+
# cgroup (v1): the container-id is part of the cgroup-path; here a plain 64-hex-match is safe.
|
|
337
|
+
try:
|
|
338
|
+
with open("/proc/self/cgroup", "r", encoding="utf-8") as file_handle:
|
|
339
|
+
match = re.search(r"[0-9a-f]{64}", file_handle.read())
|
|
340
|
+
if match is not None:
|
|
341
|
+
return match.group(0)
|
|
342
|
+
except Exception:
|
|
343
|
+
pass
|
|
344
|
+
# Fallback: the hostname equals the short container-id for containers started without an
|
|
345
|
+
# explicit hostname.
|
|
346
|
+
return socket.gethostname()
|
|
347
|
+
|
|
305
348
|
@GeneralUtilities.check_arguments
|
|
306
349
|
def use_cache(self) -> bool:
|
|
307
350
|
return self.__use_cache
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: scriptcollection
|
|
3
|
-
Version: 4.2.
|
|
3
|
+
Version: 4.2.138
|
|
4
4
|
Summary: The ScriptCollection is the place for reusable scripts.
|
|
5
5
|
Author-email: Marius Göcke <marius.goecke@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/anionDev/ScriptCollection
|
|
@@ -9,7 +9,7 @@ ScriptCollection/ProgramRunnerMock.py,sha256=uTu-aFle1W_oKjeQEmuPsFPQpvo0kRf2FrR
|
|
|
9
9
|
ScriptCollection/ProgramRunnerPopen.py,sha256=8tP0xWKeRYoGlaNB3iUh4o61O-tKtcxrS7IUqtU85C4,4091
|
|
10
10
|
ScriptCollection/ProgramRunnerSudo.py,sha256=RXsiceQ8W6a8YDk_2BPscVbIAmDIpIxqe9WHBy2r4CM,5233
|
|
11
11
|
ScriptCollection/SCLog.py,sha256=Z-HhC_CRtU3HdQflNsabFh9IJOucHcXmxMDcf58fli0,4671
|
|
12
|
-
ScriptCollection/ScriptCollectionCore.py,sha256=
|
|
12
|
+
ScriptCollection/ScriptCollectionCore.py,sha256=np8B5hkEE-BRuKknPf40RP77d6cHggdjleoNNsySznA,214596
|
|
13
13
|
ScriptCollection/UnassignedVariablesCheck.py,sha256=v59qLQ5RRvx31ouuCW7NWZj3McWENvGBPkV5ZGBmqJE,4344
|
|
14
14
|
ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
15
|
ScriptCollection/OCIImages/AbstractImageHandler.py,sha256=o129UYDtLymCRjMZBP9Puaj19ueMHoNt6UTLspfnaRc,1758
|
|
@@ -28,7 +28,7 @@ ScriptCollection/Resources/Dependencies/OpenAPIGenerator/Version.txt,sha256=hdAg
|
|
|
28
28
|
ScriptCollection/Resources/MaintenanceSite/MaintenanceSite.html,sha256=CX9S1bdOz6xU2aGfr03tJRGczQrlpn-IeODc15d5kc0,232
|
|
29
29
|
ScriptCollection/TFCPS/TFCPS_CodeUnitSpecific_Base.py,sha256=sWnTspNrdwWFuPNX0dCZYFv7U0ggtUL_-iYqToaYSV4,28896
|
|
30
30
|
ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnit.py,sha256=WT4IzlzBaY46ogBeT2rvm_TnOE7HMw-cchJyTlmH5Og,9412
|
|
31
|
-
ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py,sha256=
|
|
31
|
+
ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py,sha256=YnR9tiFgLGXdQnCs8fTMf9xHBPPjco8-Em8ln1tt-jA,23138
|
|
32
32
|
ScriptCollection/TFCPS/TFCPS_CreateRelease.py,sha256=X2NgZgbOkJsdZ6wMHB_RuS_rQCuz5oQCqzYrxyXBN9Q,6680
|
|
33
33
|
ScriptCollection/TFCPS/TFCPS_Generic.py,sha256=5vCFfDiU8bvfcnoKNs2ATS8nsl6mYXcIuX7XfYE0tvg,2116
|
|
34
34
|
ScriptCollection/TFCPS/TFCPS_MergeToMain.py,sha256=BsSV4a-NZY86MZ20d-_rYxNVAI4UzAfmEwXlRZ8qWQc,7685
|
|
@@ -55,8 +55,8 @@ ScriptCollection/TFCPS/Python/TFCPS_CodeUnitSpecific_Python.py,sha256=fqGhXNx8tK
|
|
|
55
55
|
ScriptCollection/TFCPS/Python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
56
56
|
ScriptCollection/TFCPS/Rust/TFCPS_CodeUnitSpecific_Rust.py,sha256=WhOsMpJxNGqnQGA3nJ99ruyqymxBeJxCcpK98zJduTo,1680
|
|
57
57
|
ScriptCollection/TFCPS/Rust/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
58
|
-
scriptcollection-4.2.
|
|
59
|
-
scriptcollection-4.2.
|
|
60
|
-
scriptcollection-4.2.
|
|
61
|
-
scriptcollection-4.2.
|
|
62
|
-
scriptcollection-4.2.
|
|
58
|
+
scriptcollection-4.2.138.dist-info/METADATA,sha256=SMpqXvMr8WAVy9rHkHPwsdC7EOt0u5e_B247RhQvkQc,7817
|
|
59
|
+
scriptcollection-4.2.138.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
60
|
+
scriptcollection-4.2.138.dist-info/entry_points.txt,sha256=Uh2xhKqpyqQX60Nbhq0CDDVOZKN5Gv5J9visugccKuc,5217
|
|
61
|
+
scriptcollection-4.2.138.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
|
|
62
|
+
scriptcollection-4.2.138.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|