ScriptCollection 4.2.135__py3-none-any.whl → 4.2.137__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.
@@ -38,7 +38,7 @@ from .ProgramRunnerBase import ProgramRunnerBase
38
38
  from .ProgramRunnerPopen import ProgramRunnerPopen
39
39
  from .SCLog import SCLog, LogLevel
40
40
 
41
- version = "4.2.135"
41
+ version = "4.2.137"
42
42
  __version__ = version
43
43
 
44
44
  class VSCodeWorkspaceShellTask:
@@ -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
@@ -281,8 +283,32 @@ class TFCPS_CodeUnit_BuildCodeUnits:
281
283
  image = self.tfcps_tools_general.oci_image_manager.get_registry_address_for_image_with_default_tag(self.repository, "Betterleaks")
282
284
  except Exception:
283
285
  image="ghcr.io/betterleaks/betterleaks:latest"
284
- scan_args = ["dir", "/repo", "-v"]
285
- args = ["run", "--rm", "-v", f"{self.repository}:/repo", image] + scan_args
286
+ config_file = os.path.join(self.repository, ".betterleaks.toml")
287
+ if self.sc.is_running_in_build_container():
288
+ # We run inside the build-container with the docker-socket forwarded to the host-daemon.
289
+ # A bind-mount of our in-container repository-path (e.g. "/__w/<repo>/<repo>" on a
290
+ # GitHub-runner or "/Workspace/Repository" when the pipeline is run locally) would be
291
+ # resolved by the host-daemon, where that path does not exist or points to unrelated
292
+ # data (for example test-service-volumes written there by other sibling-containers).
293
+ # The sibling betterleaks-container would then scan the wrong directory - without the
294
+ # repository-content and without ".betterleaks.toml", which causes false positives.
295
+ # Sharing our own volumes instead exposes the repository to betterleaks at the same path.
296
+ mount_arguments = ["--volumes-from", self.__get_own_container_id()]
297
+ repository_in_scan_container = self.repository
298
+ else:
299
+ # Running directly on the host: a normal bind-mount works because the path is resolved
300
+ # on the same filesystem the docker-daemon uses.
301
+ mount_arguments = ["-v", f"{self.repository}:/repo"]
302
+ repository_in_scan_container = "/repo"
303
+ scan_args = ["dir", repository_in_scan_container, "-v"]
304
+ if os.path.isfile(config_file):
305
+ # Pass the config explicitly instead of relying on auto-detection, because betterleaks
306
+ # silently falls back to the default ruleset when it does not find the config at the
307
+ # scan-root, which results in false positives.
308
+ scan_args = scan_args + ["-c", f"{repository_in_scan_container}/.betterleaks.toml"]
309
+ else:
310
+ self.sc.log.log(f"No betterleaks-config found at '{config_file}'; scanning with default ruleset only.", LogLevel.Warning)
311
+ args = ["run", "--rm"] + mount_arguments + [image] + scan_args
286
312
  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)
287
313
  if result[0] != 0:
288
314
  for line in GeneralUtilities.string_to_lines(result[1]):
@@ -291,6 +317,23 @@ class TFCPS_CodeUnit_BuildCodeUnits:
291
317
  self.sc.log.log(line, LogLevel.Error)
292
318
  raise ValueError(f"Found unignored secret findings (exit code {result[0]}). See {os.path.join(self.repository, '.betterleaks.toml')} to ignore known false positives.")
293
319
 
320
+ @GeneralUtilities.check_arguments
321
+ def __get_own_container_id(self) -> str:
322
+ # Determine the id of the container this process runs in so its volumes can be shared with
323
+ # sibling-containers via "docker run --volumes-from". The id is read from the proc-filesystem
324
+ # (most reliable) and falls back to the hostname, which equals the short container-id for
325
+ # containers that were started without an explicit hostname.
326
+ for proc_file in ["/proc/self/mountinfo", "/proc/self/cgroup"]:
327
+ try:
328
+ with open(proc_file, "r", encoding="utf-8") as file_handle:
329
+ content = file_handle.read()
330
+ except Exception:
331
+ continue
332
+ match = re.search(r"[0-9a-f]{64}", content)
333
+ if match is not None:
334
+ return match.group(0)
335
+ return socket.gethostname()
336
+
294
337
  @GeneralUtilities.check_arguments
295
338
  def use_cache(self) -> bool:
296
339
  return self.__use_cache
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptcollection
3
- Version: 4.2.135
3
+ Version: 4.2.137
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=X5Xwgmcx2gUl2qlCxmADokB7k2ngd14C0khY_-XVPoc,214596
12
+ ScriptCollection/ScriptCollectionCore.py,sha256=obr7gYratrqnSXNDotb89UqzODlIGH2UuW2dKma7rkU,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=i7bpkQaw5_g2517WXc0cwUHb9Vfq7q_51WklWsfqRxA,19631
31
+ ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py,sha256=yngSKzx_JutZnODk7vI1HxJaB8MV3wtfkrJKdVxy9ws,22468
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.135.dist-info/METADATA,sha256=v6okodlJ6oZP0xbcSbTf2CgJyuiZDjZvsNvV60k-OHI,7817
59
- scriptcollection-4.2.135.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
60
- scriptcollection-4.2.135.dist-info/entry_points.txt,sha256=Uh2xhKqpyqQX60Nbhq0CDDVOZKN5Gv5J9visugccKuc,5217
61
- scriptcollection-4.2.135.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
62
- scriptcollection-4.2.135.dist-info/RECORD,,
58
+ scriptcollection-4.2.137.dist-info/METADATA,sha256=2-e-EWKP8UEK1TRDhAmgmEZ_aQzrnS0NANvkMax_Uag,7817
59
+ scriptcollection-4.2.137.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
60
+ scriptcollection-4.2.137.dist-info/entry_points.txt,sha256=Uh2xhKqpyqQX60Nbhq0CDDVOZKN5Gv5J9visugccKuc,5217
61
+ scriptcollection-4.2.137.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
62
+ scriptcollection-4.2.137.dist-info/RECORD,,