Skip to content

Add sandbox hash subcommand to resandbox by sha256/sha1/md5#236

Merged
scsich merged 1 commit into
developfrom
fix/resandbox
May 8, 2026
Merged

Add sandbox hash subcommand to resandbox by sha256/sha1/md5#236
scsich merged 1 commit into
developfrom
fix/resandbox

Conversation

@scsich
Copy link
Copy Markdown
Contributor

@scsich scsich commented May 5, 2026

Summary

  • Adds polyswarm sandbox hash <provider> <sha256|sha1|md5> so a known sample can be resandboxed by hash without first running search hash to pull out an artifact-instance id.
  • Looks up the latest matching ArtifactInstance via api.search_hashes (next(iter(...)) so we don't drain the full list), then forwards that instance id to the existing api.sandbox_instances path.
  • Mirrors sandbox instance's flag surface (--vm_slug, --internet-disabled) and accepts -r/--hash-file / --hash-type like search hash.
  • If the hash has no known instances, fails with a clear ClickException.

Motivation

The sandbox-submission surface is confusing: sandbox instance expects an artifact-instance id (ArtifactInstance.id), but the CLI argument is named artifact-id, Polyswarm.sandbox(...) takes instance_id, and the request body sends the value as artifact_id. cc @sbneto — same value, three names depending on where you stand; worth reconciling on the API/server side too.

Test plan

  • polyswarm sandbox hash --help renders.
  • polyswarm sandbox hash <provider> <known-sha256> submits and returns a sandbox task.
  • Unknown hash fails with No artifact instances found for hash ….
  • Multiple positional hashes and -r file both work.
  • --internet-disabled and --vm_slug are forwarded.
  • Add a VCR-backed test in tests/cli_test.py::SandoxTest.

The existing `sandbox instance` subcommand requires an opaque numeric
artifact-instance id, which forces a two-step `search hash` →
`sandbox instance` workflow when you already have the hash in hand.
This adds a `sandbox hash` subcommand that resolves the hash to its
latest artifact instance under the hood and submits that instance.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@scsich scsich merged commit 0f5461f into develop May 8, 2026
1 check passed
@scsich scsich deleted the fix/resandbox branch May 8, 2026 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants