ScriptCollection 4.2.119__py3-none-any.whl → 4.2.120__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.
@@ -920,6 +920,18 @@ def AddImageToCustomRegistry()->int:
920
920
  sc.add_image_to_custom_docker_image_registry(args.remotehub,args.imagenameonremotehub,args.ownregistryaddress,args.imagenameonownregistry,args.tag,args.username,args.password)
921
921
  return 0
922
922
 
923
+ def SearchForSecrets() -> int:
924
+ parser = argparse.ArgumentParser(description="Scans the given repository for secrets using Betterleaks. Fails if unignored findings are present.")
925
+ parser.add_argument('-r', '--repository', required=False, default=None, help="Path to the repository. Defaults to the current working directory.")
926
+ verbosity_values = ", ".join(f"{lvl.value}={lvl.name}" for lvl in LogLevel)
927
+ parser.add_argument('-v', '--verbosity', required=False, default=3, help=f"Sets the loglevel. Possible values: {verbosity_values}")
928
+ args = parser.parse_args()
929
+ repository = GeneralUtilities.resolve_relative_path(args.repository, os.getcwd()) if args.repository is not None else os.getcwd()
930
+ t: TFCPS_CodeUnit_BuildCodeUnits = TFCPS_CodeUnit_BuildCodeUnits(repository, LogLevel(int(args.verbosity)), "QualityCheck", None, True, False, False)
931
+ t.search_for_secrets()
932
+ return 0
933
+
934
+
923
935
  def PrepareBuildPipelineForGitlab() -> int:
924
936
  parser = argparse.ArgumentParser(description="Prepares the build-pipeline-configuration for GitLab.")
925
937
  verbosity_values = ", ".join(f"{lvl.value}={lvl.name}" for lvl in LogLevel)
@@ -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.119"
41
+ version = "4.2.120"
42
42
  __version__ = version
43
43
 
44
44
  class VSCodeWorkspaceShellTask:
@@ -528,6 +528,11 @@ class ScriptCollectionCore:
528
528
  self.assert_is_git_repository(folder)
529
529
  self.run_program("git", f"branch -D {branchname}", folder, throw_exception_if_exitcode_is_not_zero=True)
530
530
 
531
+ @GeneralUtilities.check_arguments
532
+ def git_remove_remote_branch(self, folder: str, remotename: str, branchname: str) -> None:
533
+ self.assert_is_git_repository(folder)
534
+ self.run_program_argsasarray("git", ["push", remotename, "--delete", branchname], folder, throw_exception_if_exitcode_is_not_zero=True)
535
+
531
536
  @GeneralUtilities.check_arguments
532
537
  def git_push_with_retry(self, folder: str, remotename: str, localbranchname: str, remotebranchname: str, forcepush: bool = False, pushalltags: bool = True, verbosity: LogLevel = LogLevel.Quiet, amount_of_attempts: int = 5) -> None:
533
538
  GeneralUtilities.retry_action(lambda: self.git_push(folder, remotename, localbranchname, remotebranchname, forcepush, pushalltags, verbosity), amount_of_attempts)
@@ -70,7 +70,7 @@ class TFCPS_CodeUnit_BuildCodeUnits:
70
70
 
71
71
  self.sc.log.log(GeneralUtilities.get_line())
72
72
  self.__search_for_vulnerabilities()
73
- self.__search_for_secrets()
73
+ self.search_for_secrets()
74
74
  if self.is_pre_merge():
75
75
  self.__translate()
76
76
  self.__collect_metrics()
@@ -235,24 +235,17 @@ class TFCPS_CodeUnit_BuildCodeUnits:
235
235
  pass#TODO
236
236
 
237
237
  @GeneralUtilities.check_arguments
238
- def __search_for_secrets(self):
239
- enabled:bool=False#TODO reenable when a solution is found to ignore false positives
240
- if enabled:
241
- exe_paths=self.tfcps_tools_general.ensure_trufflehog_is_available()
242
- exe_path:str=None
243
- if GeneralUtilities.current_system_is_windows():
244
- exe_path=exe_paths["Windows"]
245
- elif GeneralUtilities.current_system_is_linux():
246
- exe_path=exe_paths["Linux"]
247
- else:
248
- raise ValueError("unsupported")#TODO check for macos
249
- result=self.sc.run_program(exe_path,"filesystem . --json",self.repository)
250
-
251
- self.sc.log.log("Secret-scan-result:")#TODO replace this by real analysis
238
+ def search_for_secrets(self) -> None:
239
+ self.sc.log.log("Search for secrets...")
240
+ image = self.tfcps_tools_general.oci_image_manager.get_registry_address_for_image_with_default_tag(self.repository, "Betterleaks", True)
241
+ args = ["run", "--rm", "-v", f"{self.repository}:/repo", image, "git", "/repo"]
242
+ 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)
243
+ if result[0] != 0:
252
244
  for line in GeneralUtilities.string_to_lines(result[1]):
253
- self.sc.log.log(line)
245
+ self.sc.log.log(line, LogLevel.Information)
254
246
  for line in GeneralUtilities.string_to_lines(result[2]):
255
- self.sc.log.log(line,LogLevel.Error)
247
+ self.sc.log.log(line, LogLevel.Error)
248
+ raise ValueError(f"Found unignored secret findings (exit code {result[0]}). See {os.path.join(self.repository, '.betterleaks.toml')} to ignore known false positives.")
256
249
 
257
250
  @GeneralUtilities.check_arguments
258
251
  def use_cache(self) -> bool:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptcollection
3
- Version: 4.2.119
3
+ Version: 4.2.120
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
@@ -22,7 +22,7 @@ Classifier: Topic :: Utilities
22
22
  Requires-Python: >=3.11
23
23
  Description-Content-Type: text/markdown
24
24
  Requires-Dist: build>=1.5.0
25
- Requires-Dist: coverage>=7.14.0
25
+ Requires-Dist: coverage>=7.14.1
26
26
  Requires-Dist: cyclonedx-bom>=7.1.0
27
27
  Requires-Dist: defusedxml>=0.7.1
28
28
  Requires-Dist: keyboard>=0.13.5
@@ -35,7 +35,7 @@ Requires-Dist: pycdlib>=1.16.0
35
35
  Requires-Dist: Pygments>=2.20.0
36
36
  Requires-Dist: pylint>=4.0.5
37
37
  Requires-Dist: pyOpenSSL>=25.3.0
38
- Requires-Dist: PyPDF>=6.11.0
38
+ Requires-Dist: PyPDF>=6.13.0
39
39
  Requires-Dist: pytest>=8.4.2
40
40
  Requires-Dist: PyYAML>=6.0.3
41
41
  Requires-Dist: qrcode>=8.2.0
@@ -6,7 +6,7 @@ Other/QualityCheck/RunTestcases.py,sha256=3vJBquOr9q1DhF4648FhY_sXS-DV_l193mE_O9
6
6
  Other/Reference/GenerateReference.py,sha256=MFzu7U1OHxgecYDi7WSulO8XRGBsgkdqV_r_jkyVF7c,369
7
7
  ScriptCollection/AnionBuildPlatform.py,sha256=OnL0V0jFGrT3ZbCRamy4LBmeGUu-cBFMbk1bhs_S64k,11781
8
8
  ScriptCollection/CertificateUpdater.py,sha256=dR5JpJDlZdjD4_pgMz7zCrt1IM7VfatmK6pULSczxQw,9693
9
- ScriptCollection/Executables.py,sha256=3-i1P60XxxoSl1meTdh-9cu9P6QuxOqa6rD7XoEI-Fo,47705
9
+ ScriptCollection/Executables.py,sha256=WGzo5IB3hcd8EB9O5uK_34dxrsm8tlk9CR6vUy3YKWA,48615
10
10
  ScriptCollection/GeneralUtilities.py,sha256=4BmzJhTPAZmKQd5YlMuX0E5Dl6fhuVkmVaCpST0WzRk,67654
11
11
  ScriptCollection/HTTPMaintenanceOverheadHelper.py,sha256=TToNtyO1XzsMbBsTBf3o0xgOK0v4Jf03qw2Z0xb2nCk,2007
12
12
  ScriptCollection/ProcessesRunner.py,sha256=o5raxIt3lknNPoPrjNzJ2bprRPJ3SnL0rrR7crraD7E,1523
@@ -15,7 +15,7 @@ ScriptCollection/ProgramRunnerMock.py,sha256=uTu-aFle1W_oKjeQEmuPsFPQpvo0kRf2FrR
15
15
  ScriptCollection/ProgramRunnerPopen.py,sha256=8tP0xWKeRYoGlaNB3iUh4o61O-tKtcxrS7IUqtU85C4,4091
16
16
  ScriptCollection/ProgramRunnerSudo.py,sha256=4lxbUFMIWMbthM5Q_QaFjvZfAsNpKlXeqfEbiofg_DI,5109
17
17
  ScriptCollection/SCLog.py,sha256=8TRy1LeYMsPOIuWUcnUNNbO5pd-cNBS-3cn-kdzP8FU,4768
18
- ScriptCollection/ScriptCollectionCore.py,sha256=aK0vKxqI_hnKqMnK3f_PYTwYpGlgDhDqycv2oIXDMvk,205101
18
+ ScriptCollection/ScriptCollectionCore.py,sha256=PUvkYxCHubk7jTqQunRFaZJCGah0LJAB3v2lgbpCbkI,205425
19
19
  ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  ScriptCollection/OCIImages/AbstractImageHandler.py,sha256=o129UYDtLymCRjMZBP9Puaj19ueMHoNt6UTLspfnaRc,1758
21
21
  ScriptCollection/OCIImages/OCIImageManager.py,sha256=2muW4hJ_a7EfavY3WVnafqZ0HC87RcZsoTuNvA3c0To,11175
@@ -32,7 +32,7 @@ ScriptCollection/Resources/CultureChooser/index.html,sha256=gxQzbrSp4WU52TqN-gcB
32
32
  ScriptCollection/Resources/MaintenanceSite/MaintenanceSite.html,sha256=CX9S1bdOz6xU2aGfr03tJRGczQrlpn-IeODc15d5kc0,232
33
33
  ScriptCollection/TFCPS/TFCPS_CodeUnitSpecific_Base.py,sha256=EMNDgkUem87aH1csz7eoSBBEKkiZMLZqZhnxKSPQWe0,27845
34
34
  ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnit.py,sha256=wLOCoMJVkhqKilJrYA_8KYesh68oUPQQnGwhxBSwZbA,9217
35
- ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py,sha256=voxWT2qr3zx7YI0TudtqQUJ1mai9bqnb6MhL9DTtnNs,16393
35
+ ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py,sha256=No-qa537U38gkVF15M91SQTUpD8j4ieUB5ptsZB2wTM,16382
36
36
  ScriptCollection/TFCPS/TFCPS_CreateRelease.py,sha256=yqGstRjRfVVGbqrcBgtYStqth2x2SvBb3y2Ht8GsuMQ,6554
37
37
  ScriptCollection/TFCPS/TFCPS_Generic.py,sha256=Tpzgiz6m3-cYCkObZOG5Uu7oM-EMoWFzzRpLl3Lblqo,2023
38
38
  ScriptCollection/TFCPS/TFCPS_MergeToMain.py,sha256=Vwj7IWmvwIICXiv7I-c6MkxbqlRWCEwzaKW6dgEUjCM,7480
@@ -291,8 +291,8 @@ build/lib/build/lib/build/lib/build/lib/ScriptCollection/TFCPS/Python/TFCPS_Code
291
291
  build/lib/build/lib/build/lib/build/lib/ScriptCollection/TFCPS/Python/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
292
292
  build/lib/build/lib/build/lib/build/lib/ScriptCollection/TFCPS/Rust/TFCPS_CodeUnitSpecific_Rust.py,sha256=WhOsMpJxNGqnQGA3nJ99ruyqymxBeJxCcpK98zJduTo,1680
293
293
  build/lib/build/lib/build/lib/build/lib/ScriptCollection/TFCPS/Rust/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
294
- scriptcollection-4.2.119.dist-info/METADATA,sha256=ypPHoDnKDvZkG9RBaUc9r5AOgx4bsj5T6l-6jSJhg3E,7697
295
- scriptcollection-4.2.119.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
296
- scriptcollection-4.2.119.dist-info/entry_points.txt,sha256=_vnVTrGJc_z-DTPLvaYyyOpDEQLz0bdO2OLN3_ZmeR8,4978
297
- scriptcollection-4.2.119.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
298
- scriptcollection-4.2.119.dist-info/RECORD,,
294
+ scriptcollection-4.2.120.dist-info/METADATA,sha256=w0VMh3kxFGQ9r0RA2aH7GP8k-POpoiZ8R2dAaVswz44,7697
295
+ scriptcollection-4.2.120.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
296
+ scriptcollection-4.2.120.dist-info/entry_points.txt,sha256=ySZ09rptnBxyfpU-K62zmoUFH-0xWZUxzoPScoXubrg,5045
297
+ scriptcollection-4.2.120.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
298
+ scriptcollection-4.2.120.dist-info/RECORD,,
@@ -56,6 +56,7 @@ scremovefile = ScriptCollection.Executables:RemoveFile
56
56
  scremovefolder = ScriptCollection.Executables:RemoveFolder
57
57
  screname = ScriptCollection.Executables:Rename
58
58
  screplacesubstringsinfilenames = ScriptCollection.Executables:ReplaceSubstringsInFilenames
59
+ scsearchforsecrets = ScriptCollection.Executables:SearchForSecrets
59
60
  scsearchinfiles = ScriptCollection.Executables:SearchInFiles
60
61
  scsetcontentoffile = ScriptCollection.Executables:SetContentOfFile
61
62
  scshow2faasqrcode = ScriptCollection.Executables:Show2FAAsQRCode