ScriptCollection 4.4.63__py3-none-any.whl → 4.4.64__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,18 +38,26 @@ class AgentRunner:
38
38
  self.verbose = verbose
39
39
 
40
40
  @GeneralUtilities.check_arguments
41
- def run(self, prompt: str, interactive: bool, repository: str, configuration_overrides: AgentRunnerConfiguration, additional_folders: list[str]) -> int:
41
+ def run(self, prompt: str, interactive: bool, repository: str, configuration_overrides: AgentRunnerConfiguration, additional_folders: list[str], mount_docker_socket: bool) -> int:
42
42
  # Returns the exit-code of the container, which is the exit-code of the initialization-script if it failed and the exit-code of the agent otherwise.
43
43
  # In interactive mode the prompt is optional: without a prompt the agent is started without an initial instruction and the user can instruct it interactively.
44
44
  # Every value of configuration_overrides which is not None overrides the corresponding value from the configuration-file.
45
45
  # additional_folders are absolute host-folders which are additionally mounted (read-write) under "/Workspace/Other/AdditionalResources/<folder-name>".
46
+ # mount_docker_socket is deliberately not part of the configuration-file: it must be a conscious decision for every single run (see __print_docker_socket_warning).
46
47
  GeneralUtilities.assert_condition(interactive or prompt is not None, "A prompt is required when the agent is not run in interactive mode.")
47
48
  self.__assert_is_git_root_dir(repository)
48
49
  agentRunnerConfiguration: AgentRunnerConfiguration = self.__load_configuration(repository, configuration_overrides)
49
50
  initialization_script = self.__get_initialization_script(repository)
50
51
  additional_folder_volume_arguments = self.__get_additional_folder_volume_arguments(additional_folders)
52
+ if mount_docker_socket:
53
+ self.__print_docker_socket_warning()
54
+ additional_folder_volume_arguments = additional_folder_volume_arguments + ["--volume", "/var/run/docker.sock:/var/run/docker.sock"]
51
55
  return self.__run_sandbox(repository, agentRunnerConfiguration, prompt, interactive, initialization_script, additional_folder_volume_arguments)
52
56
 
57
+ @GeneralUtilities.check_arguments
58
+ def __print_docker_socket_warning(self) -> None:
59
+ GeneralUtilities.write_message_to_stderr("Warning: Mounting the docker-socket of the host into the sandbox is dangerous because it makes the sandbox ineffective.")
60
+
53
61
  @GeneralUtilities.check_arguments
54
62
  def __get_additional_folder_volume_arguments(self, additional_folders: list[str]) -> list[str]:
55
63
  # Every additional folder is mounted under "/Workspace/Other/AdditionalResources/<folder-name>" (preserving the folder-name).
@@ -26,8 +26,9 @@ def RunAgentInSandbox() -> int:
26
26
  parser.add_argument('-v', '--verbose', action='store_true', required=False, default=False, help='Enables verbose output.')
27
27
  parser.add_argument('-c', '--codingagent', default=None, required=False, choices=[coding_agent.value for coding_agent in CodingAgent], help='Coding-agent which should be used. Overrides the value from ".ScriptCollection/AgentSandboxConfiguration.ini".')
28
28
  parser.add_argument('--image', default=None, required=False, help='OCI-image which should be used for the sandbox: either an image-name defined in ".ScriptCollection/OCIImages/ImageDefinition.csv" or an image-address including tag. Overrides the value from ".ScriptCollection/AgentSandboxConfiguration.ini".')
29
- parser.add_argument('--dropcapabilities', default=None, required=False, choices=["true", "false"], help='Defines whether all capabilities should be dropped in the sandbox. Overrides the value from ".ScriptCollection/AgentSandboxConfiguration.ini".')
29
+ parser.add_argument('-s','--dropcapabilities', default=None, required=False, choices=["true", "false"], help='Defines whether all capabilities should be dropped in the sandbox. Overrides the value from ".ScriptCollection/AgentSandboxConfiguration.ini".')
30
30
  parser.add_argument('-a', '--additionalfolder', action='append', default=None, required=False, help='Folder which should additionally be mounted (read-write) into the sandbox under "/Workspace/Other/AdditionalResources/<folder-name>". Can be given multiple times.')
31
+ parser.add_argument('-d','--mountdockersocket', action='store_true', required=False, default=False, help='Mounts the docker-socket of the host (/var/run/docker.sock) into the sandbox so that the agent can use docker. DANGEROUS: this effectively gives the agent administrator-access to the docker-daemon of the host and makes the restrictions of the sandbox ineffective. Can only be set via this argument (not in the configuration-file); a warning is printed to stderr.')
31
32
  args = parser.parse_args()
32
33
  repo=os.getcwd()
33
34
  if args.repository is not None:
@@ -43,7 +44,7 @@ def RunAgentInSandbox() -> int:
43
44
  if args.additionalfolder is not None:
44
45
  additional_folders = [GeneralUtilities.resolve_relative_path(additional_folder, os.getcwd()) for additional_folder in args.additionalfolder]
45
46
  ar = AgentRunner(args.verbose)
46
- return ar.run(args.prompt, args.interactive, repo, configuration_overrides, additional_folders)
47
+ return ar.run(args.prompt, args.interactive, repo, configuration_overrides, additional_folders, args.mountdockersocket)
47
48
 
48
49
 
49
50
  def FilenameObfuscator() -> int:
@@ -40,7 +40,7 @@ from .ProgramRunnerBase import ProgramRunnerBase
40
40
  from .ProgramRunnerPopen import ProgramRunnerPopen
41
41
  from .SCLog import SCLog, LogLevel
42
42
 
43
- version = "4.4.63"
43
+ version = "4.4.64"
44
44
  __version__ = version
45
45
 
46
46
  class VSCodeWorkspaceShellTask:
@@ -198,12 +198,13 @@ class TFCPS_CodeUnit_BuildCodeUnits:
198
198
  hook.run_after_codeunit_was_built(tFCPS_CodeUnit_BuildCodeUnit)
199
199
  self.sc.log.log(GeneralUtilities.get_line())
200
200
 
201
- self.search_for_secrets()
202
201
  self.tfcps_tools_general.generate_svg_files_from_plantuml_files_for_repository(self.repository, self.use_cache())
203
202
  self.tfcps_tools_general.generate_svg_files_from_vega_files_for_repository(self.repository, self.use_cache())
204
203
  self.tfcps_tools_general.generate_svg_files_from_vegalite_files_for_repository(self.repository, self.use_cache())
205
204
  self.__do_project_linting(self.repository)
205
+ self.__update_agent_sandbox_image(self.repository)
206
206
  self.__normalize_line_endings_of_common_files()
207
+ self.search_for_secrets()
207
208
 
208
209
  self.sc.log.log(GeneralUtilities.get_line())
209
210
 
@@ -238,6 +239,46 @@ class TFCPS_CodeUnit_BuildCodeUnits:
238
239
  self.sc.log.log(GeneralUtilities.get_line())
239
240
 
240
241
 
242
+ @GeneralUtilities.check_arguments
243
+ def __update_agent_sandbox_image(self, repository_folder: str) -> None:
244
+ """Sets the value "image" in "<repository>/.ScriptCollection/AgentSandboxConfiguration.ini" to the SCBuilder-image (address including tag)
245
+ defined in "<repository>/.ScriptCollection/OCIImages/ImageDefinition.csv".
246
+ Nothing is done if one of these files does not exist or if the image-definition-file does not contain an entry for SCBuilder."""
247
+ image_definition_file = os.path.join(repository_folder, ".ScriptCollection", "OCIImages", "ImageDefinition.csv")
248
+ agent_sandbox_configuration_file = os.path.join(repository_folder, ".ScriptCollection", "AgentSandboxConfiguration.ini")
249
+ if not os.path.isfile(image_definition_file) or not os.path.isfile(agent_sandbox_configuration_file):
250
+ return
251
+ scbuilder_image: str = None
252
+ for line in GeneralUtilities.read_nonempty_lines_from_file(image_definition_file):
253
+ if line.startswith("SCBuilder;"):
254
+ columns = line.split(";")
255
+ scbuilder_image = f"{columns[1]}:{columns[2]}"
256
+ break
257
+ if scbuilder_image is None:
258
+ return
259
+ self.sc.log.log(f"Set image of agent-sandbox to '{scbuilder_image}'...", LogLevel.Debug)
260
+ section_header = "[AgentSandboxConfiguration]"
261
+ image_line = f"image = {scbuilder_image}"
262
+ lines: list[str] = GeneralUtilities.read_lines_from_file(agent_sandbox_configuration_file)
263
+ updated_lines: list[str] = []
264
+ current_section: str = None
265
+ image_was_set = False
266
+ for line in lines:
267
+ stripped_line = line.strip()
268
+ if stripped_line.startswith("[") and stripped_line.endswith("]"):
269
+ current_section = stripped_line
270
+ elif current_section == section_header and re.match(r"^image\s*=", stripped_line):
271
+ line = image_line
272
+ image_was_set = True
273
+ updated_lines.append(line)
274
+ if not image_was_set:
275
+ if section_header in [line.strip() for line in updated_lines]:
276
+ updated_lines.insert([line.strip() for line in updated_lines].index(section_header) + 1, image_line)
277
+ else:
278
+ updated_lines.extend([section_header, image_line])
279
+ if updated_lines != lines:
280
+ GeneralUtilities.write_lines_to_file(agent_sandbox_configuration_file, updated_lines)
281
+
241
282
  @GeneralUtilities.check_arguments
242
283
  def __do_project_linting(self, repository_folder: str) -> None:
243
284
  self.sc.log.log("Do project-linting...")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptcollection
3
- Version: 4.4.63
3
+ Version: 4.4.64
4
4
  Summary: The ScriptCollection is the place for reusable scripts.
5
5
  Author-email: Marius Göcke <marius.goecke@gmail.com>
6
6
  License-Expression: GPL-3.0-only
@@ -1,7 +1,7 @@
1
- ScriptCollection/AgentRunner.py,sha256=eVKKsSHywH9hiEkj9l0vT34vETImK7E-ajPi7XoOsKU,18062
1
+ ScriptCollection/AgentRunner.py,sha256=uEtrUVb_BNwxytkmUe95ckBHZDG3RoJfOw1SSLYndUc,18750
2
2
  ScriptCollection/ArbTranslationsOrganizer.py,sha256=3TO4fjkYADcHGyUXdiQk-RtfCxtf9ojuBS3CbZtgXBE,12218
3
3
  ScriptCollection/CertificateUpdater.py,sha256=yZc7KESc1F_Mc6HP2UfLmNHRc2MvtVqp0t60J_CqY3s,9755
4
- ScriptCollection/Executables.py,sha256=0rJTjsOvvSNWG9Qz5e27rU10XwphalRxvf014wCwt8E,81132
4
+ ScriptCollection/Executables.py,sha256=rJO6dVTQ_UvSF5mNIHOpNaXnmhxPgejI2wtqWMFbQzw,81636
5
5
  ScriptCollection/GeneralUtilities.py,sha256=kW6y52rdD-dJrjCtIgsdwYinz6FtclGj-xc_4tL1MUg,80022
6
6
  ScriptCollection/HTTPMaintenanceOverheadHelper.py,sha256=TToNtyO1XzsMbBsTBf3o0xgOK0v4Jf03qw2Z0xb2nCk,2007
7
7
  ScriptCollection/ProcessesRunner.py,sha256=wtNFdmj9klETTIDUSE90vaR5ClEX4V7dgJNVbp9_wi0,1381
@@ -12,7 +12,7 @@ ScriptCollection/ProgramRunnerSudo.py,sha256=vwKq-MOcqsgiKhSf-MBUDBC_UyaU8evP3Ro
12
12
  ScriptCollection/RepositoryDiagramGenerator.py,sha256=K_u2NW_p4ozdWD50irJEkkcDVa70TcUJpZN63TeXSLw,7092
13
13
  ScriptCollection/RepositoryHistoryAnalyzer.py,sha256=u9141B9D-Kef-9uo3yR7BXKUMzIKLVsesnYk7H-cWm4,6157
14
14
  ScriptCollection/SCLog.py,sha256=Fjf8Pdi63cXHGMxL_aI6A0dwGm7QIfrv3czjvpSUlaM,4705
15
- ScriptCollection/ScriptCollectionCore.py,sha256=U6SsZtxPPnELu5DTQa-ypGXj3nL2kd_TMCBEg8d_8HE,310633
15
+ ScriptCollection/ScriptCollectionCore.py,sha256=Lrv7VtGaEGChRSuw7uRM63bP4_Fro0gERbAQoR8SEEQ,310633
16
16
  ScriptCollection/TestKind.py,sha256=jqLJwNvQeyea7SZf-UFzMC9pM0znv4do7FIC1xq8u9M,1672
17
17
  ScriptCollection/UnassignedVariablesCheck.py,sha256=8xNcp1D5HeOLO1a1NEerq2TsnpFhw7yzYPkaay-oisY,3804
18
18
  ScriptCollection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -40,7 +40,7 @@ ScriptCollection/TFCPS/TFCPS_BuildCodeUnitsHook.py,sha256=67_DQwoH5bhxxSmwtuAeoW
40
40
  ScriptCollection/TFCPS/TFCPS_CodeSpellCheck.py,sha256=zV62O7UiGjewx1yQUIWmUJ9D-5ipkV_f28uNhp-JWUs,5306
41
41
  ScriptCollection/TFCPS/TFCPS_CodeUnitSpecific_Base.py,sha256=Rh7S84B8QbeWn5qJxRItoI7jquJYvFnNRi_WiX3FjWo,40414
42
42
  ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnit.py,sha256=CB0K8OZNtQESdS2pqX9RQqN-lI5M-cbmXYOR0rbuRlk,9741
43
- ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py,sha256=n_jkEWkZBRL-7id-OLAZ6HiAh2nh9to3lOLFg9ujGNc,63983
43
+ ScriptCollection/TFCPS/TFCPS_CodeUnit_BuildCodeUnits.py,sha256=-JbYwpBxWMU1cKavEI05Lua-aRKhlvl7Na8j0fOgiOE,66506
44
44
  ScriptCollection/TFCPS/TFCPS_CreateRelease.py,sha256=BVK3fpEyjcXYVHIb6YYLH7bWe6iKRaCtPrJ3tXAemYw,6582
45
45
  ScriptCollection/TFCPS/TFCPS_FindingsSorter.py,sha256=3ChuKf-Myr3sBtQhYGw6dHlk93HO6PAH-Jq1oPYdW1s,4804
46
46
  ScriptCollection/TFCPS/TFCPS_Generic.py,sha256=mRBcf7XuNWOSXbZYc3NuJow18AMZ30D6Z-BtyNYfNcM,2072
@@ -75,8 +75,8 @@ ScriptCollection/TFCPS/Rust/TFCPS_CodeUnitSpecific_Rust.py,sha256=yyjWPMHQjPLkML
75
75
  ScriptCollection/TFCPS/Rust/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
76
76
  ScriptCollection/TFCPS/TypeScript/TFCPS_CodeUnitSpecific_TypeScript.py,sha256=ILVhJHvwG5TvPBBqSvyACYb7W9QnWrJpxKgHu8IQu4g,9249
77
77
  ScriptCollection/TFCPS/TypeScript/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
78
- scriptcollection-4.4.63.dist-info/METADATA,sha256=WTHUJeoQlXMiqpJN4pFzcYd2xcFFFn45OLClRblrBfs,8032
79
- scriptcollection-4.4.63.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
80
- scriptcollection-4.4.63.dist-info/entry_points.txt,sha256=kI-HqAydo8a0FGjGeXh6i1pGU73Pit0xACdjxBxNkis,6254
81
- scriptcollection-4.4.63.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
82
- scriptcollection-4.4.63.dist-info/RECORD,,
78
+ scriptcollection-4.4.64.dist-info/METADATA,sha256=LQVxzf1GkFurDhG66cIZom6rk6ksdJIpC_n2OgB_Ew0,8032
79
+ scriptcollection-4.4.64.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
80
+ scriptcollection-4.4.64.dist-info/entry_points.txt,sha256=kI-HqAydo8a0FGjGeXh6i1pGU73Pit0xACdjxBxNkis,6254
81
+ scriptcollection-4.4.64.dist-info/top_level.txt,sha256=hY2hOVH0V0Ce51WB76zKkIWTUNwMUdHo4XDkR2vYVwg,17
82
+ scriptcollection-4.4.64.dist-info/RECORD,,