fix(builder): improve artifact packaging with optional helper support

Update move_first_existing function to handle optional artifacts gracefully
instead of raising FileNotFoundError. When optional artifacts are missing,
append informative messages to stdout_err instead of failing the build.

Also update agent icons to reference external PNG files instead of embedded
base64 data for better maintainability.
This commit is contained in:
Aryma
2026-04-15 05:54:00 +07:00
parent 0c209d7201
commit dfb7ea177c
5 changed files with 18 additions and 9 deletions

View File

@@ -648,12 +648,17 @@ NOTE: v2.3.2+ uses a different BOF loader than v2.3.1 and they are not compatibl
StepSuccess=True
))
resp.status = BuildStatus.Success
def move_first_existing(candidates, target_path):
missing_optional_artifacts = []
def move_first_existing(candidates, target_path, required=False):
for candidate in candidates:
if os.path.exists(candidate):
shutil.move(candidate, target_path)
return
raise FileNotFoundError(f"Unable to locate artifact for {target_path}: {candidates}")
return True
if required:
raise FileNotFoundError(f"Unable to locate artifact for {target_path}: {candidates}")
missing_optional_artifacts.append((target_path, candidates))
return False
targetExeAsmPath = "/srv/ExecuteAssembly.exe"
targetPowerPickPath = "/srv/PowerShellHost.exe"
@@ -685,6 +690,10 @@ NOTE: v2.3.2+ uses a different BOF loader than v2.3.1 and they are not compatibl
f"{agent_build_path.name}/{buildPath}/AresInterop.dll",
f"{agent_build_path.name}/AresInterop/bin/Release/net451/AresInterop.dll",
], targetInteropPath)
if missing_optional_artifacts:
stdout_err += "\nOptional helper artifacts were not packaged:\n" + "\n".join(
f"{target}: {candidates}" for target, candidates in missing_optional_artifacts
)
if self.get_parameter('output_type') == "Source":
shutil.make_archive(f"/tmp/{agent_build_path.name}/source", "zip", f"{agent_build_path.name}")
await SendMythicRPCPayloadUpdatebuildStep(MythicRPCPayloadUpdateBuildStepMessage(