Dosu LogoDosu Logo
Ask
Join our Discord
Organization avatar
HashHivePublic
EvilBit Labs LLC
DocumentsHashHive
phase-2b-resource-management
phase-2b-resource-management
Type
External
Status
Published
Created
Jul 18, 2026
Updated
Jul 18, 2026
Source
docs/v2_rewrite_implementation_plan/phase-2b-resource-management.md

Phase 2b: Resource Management#

This phase introduces full support for file-based resources within CipherSwarm. These include wordlists, rule files, masks, and other artifacts required for hashcat operations. All uploads are stored in MinIO using presigned URLs, with metadata tracked in the database.

This phase was previously Phase 4 but has been moved up to Phase 2b to enable Web UI support in Phase 3.

See Phase 2 - Part 2 for UI endpoint scaffolding. This document defines the backend service implementation.


Table of Contents#

  • Phase 2b: Resource Management
    • Table of Contents
    • Goals
    • Required Endpoints (Web UI)
    • Access Control
    • Validation & Deduplication
    • Resource Lifecycle
    • Notes
    • Test Cases
    • Implementation Tasks

Goals#

  • Integrate MinIO object storage for resource file handling
  • Store file metadata (size, line count, hash, type, etc.) in the DB
  • Issue presigned upload and download URLs to users and agents
  • Detect duplicates using content hashing
  • Support access control, sensitivity tagging, and validation
  • Allow inline editing of small text-based files (e.g. masks, rules)
  • Allow linking resources to attacks with GUID references
  • Ensure uploaded resources never orphan or bypass backend registration

Required Endpoints (Web UI)#

MethodPathDescription
POST/api/v1/web/resources/Register upload, return presigned PUT URL
GET/api/v1/web/resources/List resources by type/project/visibility
GET/api/v1/web/resources/{id}Get metadata
GET/api/v1/web/resources/{id}/previewFirst few lines of file
PATCH/api/v1/web/resources/{id}Update metadata (name, tags, visibility)
DELETE/api/v1/web/resources/{id}Delete resource if unlinked
GET/api/v1/web/resources/{id}/contentGet raw text (editable files only)
PATCH/api/v1/web/resources/{id}/contentSave updated content
POST/api/v1/web/resources/{id}/refresh_metadataRevalidate size/checksum

Access Control#

RolePermissions
AdminFull read/write/delete on all resources
Power UserCan upload, view, edit, delete project-assigned resources
UserCan view only non-sensitive resources or those explicitly assigned to project

Validation & Deduplication#

  • Use MD5 or SHA-256 hash to detect duplicates (stored in DB)
  • Prevent multiple uploads of identical files
  • Raise error if file is already linked to an active attack or campaign - Allow user to link to the existing resource rather than reuploading

Resource Lifecycle#

  1. Upload Registration

    • Client posts metadata (name, resource_type, project_id, etc.)
    • Server returns presigned URL for upload
    • DB record created with status = pending
  2. Client Uploads File

    • PUT request directly to MinIO using presigned URL
  3. Metadata Refresh

    • Client triggers POST /refresh_metadata
    • Server:
      • Downloads file in thread
      • Computes hash, byte size, line count
      • Marks status = active
  4. Validation (Optional)

    • Client may preview or validate lines via GET /lines
  5. Link to Attack

    • Attack refers to resource by DB id

Notes#

  • Presigned URLs should expire after 15 minutes
  • Validate that uploaded files match declared resource_type
  • If the resource does not successfully upload, the resource should be deleted from the database.
  • Inline editing should only be allowed if:
    • Size < 1MB
    • Line count < 5,000 (configurable)
  • Deletion must only be allowed if resource is not referenced by any attack

Test Cases#

  • Upload a valid rule file and validate it line by line
  • Upload a duplicate wordlist and reject it
  • Upload large file and verify preview/edit is disabled
  • Attempt to delete linked resource → should fail
  • Upload, then link to attack, then unlink, then delete → should succeed

Implementation Tasks#

  • Use minio-py for all MinIO access (lightweight and sufficient for presigned flow) task_id:minio.minio_py_support
    • All blocking operations must use asyncio.to_thread(...) inside FastAPI
  • Add MinioContainer from testcontainers.minio support to enable integration tests for MinIO-based services task_id:testcontainers.minio_support (see Testcontainers MinIO Support) - This is partially implemented in tests/conftest.py, but needs to be fully implemented and should be tested.
  • Create StorageService class task_id:minio.storage_service - This is now fully implemented and tested in app/core/services/storage_service.py.
    • Stub out the class and functions and add tests for them. test_id:minio.storage_service_stub - Fully implemented and tested.
    • presign_upload(bucket, key)
    • presign_download(bucket, key)
    • get_file_stats(bucket, key) → byte size, line count, checksum
  • Create Pydantic + SQLAlchemy models for AttackResourceFile task_id:minio.attack_resource_file_model
    • Fields: name, resource_type, guid, bucket, key, size_bytes, line_count, checksum, sensitivity, project_id
    • Enum: resource_type: [word_list, rule_list, mask_list, charset, dynamic_word_list]
  • Add upload registration endpoint: task_id:minio.upload_registration_endpoint - This is partially implemented (see app/api/v1/endpoints/web/resources.py as upload_resource_metadata(...)), it needs to be wired to use the StorageService, and needs to be fully tested. The upload registration endpoint is used to register a new resource with the database and return a presigned URL for the client to upload the file to. A background task should be created to verify the file was uploaded successfully after a configurable amount of time (default 15 minutes, set in app/core/config.py, tests should override this to a very short value) or delete the resource if it is not uploaded after that time, unless the client notifies the server that the file was uploaded successfully via the upload verification endpoint.
    • POST /api/v1/web/resources/ returns:
      • DB record ID
      • presigned PUT URL
      • file key format: resources/{resource_id}/{filename}
    • Ensure that appropriate tests are added to tests/integration/web/test_web_resources_storage.py to test the upload registration endpoint, with one success and two failure tests.
  • Add a new field to the AttackResourceFile model: is_uploaded: bool - This field should be set to True when the file is uploaded successfully and False by default. If the field is true, the verify_upload_and_cleanup(...) task should log that the file was uploaded successfully and exit without deleting the resource.
  • Add upload verification endpoint: task_id:minio.upload_verification_endpoint - The upload verification endpoint allows the client to notify the server that the file was uploaded successfully. This is used to update the resource metadata and set the is_uploaded field to True.
    • POST /resources/{id}/uploaded re-fetches size/lines/checksum and updates the resource metadata.
    • Ensure that appropriate tests are added to tests/integration/web/test_web_resources_storage.py to test the upload verification endpoint, with one success and two failure tests.
  • Add metadata refresh: task_id:minio.metadata_refresh
    • POST /resources/{id}/refresh_metadata re-fetches size/lines/checksum
    • Run in thread-safe context
    • Ensure that appropriate tests are added to tests/integration/web/test_web_resources_storage.py to test the metadata refresh endpoint, with one success and two failure tests.
  • Audit app/api/v1/endpoints/web/resources.py to ensure that all endpoints that interact with file-backed resources are using the StorageService to access the file content.
    • Ensure that appropriate tests are added to tests/integration/web/test_web_resources_storage.py to test the content validation endpoint, with one success and two failure tests.
    • Many endpoints currently have tests in tests/integration/web/test_web_resources.py and should rely on the web-based endpoints to test the content validation endpoint.
    • The resource_service should be updated to use the StorageService if it is not already.
    • Check the following endpoints:
      • get_resource_content(...) - task_id:minio.get_resource_content_endpoint
      • list_wordlists(...) - task_id:minio.list_wordlists_endpoint
      • list_rulelists(...) - task_id:minio.list_rulelists_endpoint
      • list_resource_lines(...) - task_id:minio.list_resource_lines_endpoint
      • add_resource_line(...) - task_id:minio.add_resource_line_endpoint
      • update_resource_line(...) - task_id:minio.update_resource_line_endpoint
      • delete_resource_line(...) - task_id:minio.delete_resource_line_endpoint
      • get_resource_preview(...) - task_id:minio.get_resource_preview_endpoint
      • list_resources(...) - task_id:minio.list_resources_endpoint
      • upload_resource_metadata(...) - task_id:minio.upload_resource_metadata_endpoint
      • audit_orphan_resources(...) - task_id:minio.audit_orphan_resources_endpoint
      • get_resource_detail(...) - task_id:minio.get_resource_detail_endpoint
      • upload_resource_content_chunk_complete(...) - task_id:minio.upload_resource_content_chunk_complete_endpoint
  • Add orphan audit: task_id:minio.orphan_audit - This is partially implemented (see app/api/v1/endpoints/web/resources.py as audit_orphan_resources(...)), it needs to be wired to use the StorageService, and needs to be fully tested. The orphan audit is used to ensure that no MinIO objects exist without matching DB rows.
    • Ensure no MinIO objects exist without matching DB rows
Documents
.impeccable
0001-agent-enrollment-two-token-exchange
0002-docker-supervision-over-pm2
0003-bind-agent-to-enrollment-token
0004-agent-api-revisable-until-1.0
0005-version-public-api-after-1.0
0006-seaweedfs-over-minio
0007-three-api-surfaces
0008-betterauth-over-handrolled-jwt
0009-postgres-task-store-bullmq-orchestration
0010-schema-first-drizzle-zod
0011-pull-advisory-notify-task-distribution
0012-in-memory-websocket-v1-redis-deferred
0013-route-as-spec-hono-zod-openapi
0014-turborepo-bun-over-nx
0015-append-only-telemetry-timescaledb-rrd
0016-server-fanout-bus
0017-adaptive-task-sizing-lease
0018-real-db-integration-test-lane
0019-campaign-archiving-immutable-lifecycle
155-ac-traceability-matrix
155-task-distribution-assignment-spec
156-ac-traceability-matrix
156-object-storage-file-management-spec
160-login-project-selection-ui
2026-05-25-websocket-realtime-infrastructure-requirements
2026-05-29-dashboard-stats-and-read-endpoint-contract-requirements
2026-05-31-openapi-auto-generation-migration-requirements
2026-06-08-results-analysis-export-ui-requirements
2026-06-19-task-distribution-architecture
2026-06-20-campaign-archiving-requirements
2026-06-30-hash-export-import-search-requirements
227-spa-deep-link-refresh-redirect-spec
94-p0-cracker-binary-management-agent-auto-update
96-keyspace-task-distribution-spec
97-task-preemption-spec
99-attack-complexity-state-machine-spec
AGENTS
AGENTS
AI_POLICY
AI_POLICY
ARCHITECTURE
ARCHITECTURE
Agent_Authentication_&_Authorization
Agent_Heartbeat_&_Error_Handling
Agent_List_&_Detail_UI
Base Model Schema System
BullMQ_Queue_Architecture_&_Redis_Integration
CLAUDE
CONTRIBUTING
CONTRIBUTING
Campaign_Creation_Wizard_UI
Campaign_List_&_Detail_UI
Campaign_Orchestration_API
Code Quality Automation with Husky and Kiro Hooks
Core_Flows__HashHive_User_Journeys
Dashboard_&_Real-Time_Monitoring_UI
Dashboard_Stats_API_Endpoint_(GET__api_v1_dashboard_stats)
Development Workflow and Tooling Integration
ESLint and Formatting Configuration
Epic_Brief__HashHive_-_Modern_Distributed_Password_Cracking_Platform
GOTCHAS
GOTCHAS
Health Check Endpoint Enhancements
Login_&_Project_Selection_UI
MERN_proposal
Mixed Hash Type Detection & Automatic Campaign Splitting (#202)
MongoDB Connection Management
Object_Storage_&_File_Management
Project_Selection_&_User_Authentication_API
README
README
README
README
README
README
Real-Time_Events_&_WebSocket_Infrastructure
Resource_Management_API
Resource_Management_UI
Results_API_&_CSV_Export_(Dashboard_Backend)
Results_Analysis_&_Export_UI
SECURITY
SECURITY
STRATEGY
Task_Distribution_&_Assignment
Tech_Plan__HashHive_Architecture
Testing Strategy for Database and Models
advanced_task_scheduler
agent
agent-resource-protocol
agent-server-collaboration-vision
agent-token-rotation
agent_notes
agent_sync_extensions
agent_v1_contract_violations
allow_hybrid_hash_lists
attack
attack_notes
authentication_cleanup
back-compat-credential-format-migration
barrel-plus-subdir-service-split
brute_force_attack_editor
bullmq-jobid-dedup-requires-eviction
bun-test-mock-module-import-order
campaign_list_view
campaign_notes
campaigns
ci_check.prompt
code_review.prompt
contract-test-mocks-mirror-service-not-schema
copilot-instructions
core_algorithm_implementation_guide
crackable_uploads_plan
dashboard-read-endpoint-contract
dashboard-ux
default_config_suggestions
development
development
feat-agent-list-detail-ui
feat-betterauth-project-selection-rbac
feat-campaign-list-detail-ui
feat-masklist-keyspace
form-submit-payload-null-checks-2026-05-19
full_testing_architecture
getbytext-collision-waitfor-timeout
hard_password_attack_strategies
hash_hive_gap_analysis
health_status_screen
implementation_plan
learned_rules_parser_plan
llmstxt.prompt
markov_autogen_plan
new_dictionary_attack_editor
new_mask_attack_editor
openldap-testcontainer-bootstrap-race
performance_tuning.prompt
phase-1-core-infrastructure
phase-2-api-implementation
phase-2-api-implementation-part-1
phase-2-api-implementation-part-2
phase-2-api-implementation-part-3
phase-2b-resource-management
phase-2c-refactor-cleanup
phase-3-e2e-test-coverage-plan
phase-3-step-1
phase-3-step-2
phase-3-step-3
phase-3-step-4
phase-3-step-5
phase-3-web-ui-foundation
phase-4-containerization-deployment
phase-5-task-distribution
phase-6-monitoring-testing-documentation
playwright-shared-seed-user-last-project-id-flake
playwright-visual-baselines
pre-prod-wire-rename-and-schema-version-bump
previous_password_dictionary_attack_editor
projection-narrows-zrecord-wire-shape
psycopg_migration
radix-roving-focus-preventdefault-breaks-keyboard-nav
reactflow-position-by-array-index-2026-05-19
rule_explanation
salvage_templates
security_hardening.prompt
shadcn-radix-non-destructive-add-on-tailwind-v4
shared-zod-openapi-wire-contract-mirror-2026-05-25
spa_to_ssr
summary
template
test-coverage-plan
testcontainers_minio_support
testing
testing
user_flows_notes
v2-upgrade-overview
v2_agent_api_removal
work_next_task.prompt