Skip to content

Replace text inputs with proper selectors for Agent advanced hashcat configuration #658

@unclesp1d3r

Description

@unclesp1d3r

Problem

Currently, the Agent creation/edit form uses plain text inputs for advanced hashcat configuration options like opencl_devices and backend_device. This approach has several issues:

  • Poor UX: Users must manually enter comma-separated integers without guidance
  • Error-prone: No validation of valid values at input time
  • Lack of discoverability: Users don't know what values are valid without consulting hashcat documentation
  • Inconsistent with best practices: Modern forms should use appropriate input types for constrained value sets

Current Implementation

File: app/views/agents/_form.html.erb

The form currently uses:

<%= a.input :backend_device,
            hint: "Backend devices to use, separated with commas, leave blank to let hashcat decide" %>
<%= a.input :opencl_devices,
            hint: "OpenCL device types to use, integers separated with commas, leave blank to let hashcat decide" %>

Model: app/models/advanced_configuration.rb

  • Both fields are stored as strings
  • Values are comma-separated lists of integers

Proposed Solution

1. OpenCL Devices Field

Replace the text input with a multi-select checkbox group or dropdown multi-select.

Valid options (per hashcat documentation):

  • 1 - CPU
  • 2 - GPU
  • 3 - FPGA, DSP, Co-Processor

Implementation:

  • Use collection_check_boxes or similar to render checkboxes for each device type
  • Convert selected values to comma-separated string on save
  • Parse comma-separated string to checked values on load

2. Backend Device Field

This field is context-dependent - it should show devices that the agent has reported during initial configuration.

Proposed approach:

  • For new agents: Keep as text input (agent hasn't configured yet) OR hide the field entirely until first check-in
  • For existing agents: Display a checkbox list of all devices known for that specific agent (from the devices array attribute)
  • Convert selections to comma-separated list of device indices
  • Add helper text explaining that device indices correspond to the order in the Capabilities tab

3. Additional Improvements

  • Add form validation to ensure only valid integers are submitted
  • Consider adding a "Let hashcat decide" checkbox that clears the field when checked
  • Update form hints to be more descriptive
  • Add visual indicators showing which devices are selected

Implementation Checklist

  • Update app/views/agents/_form.html.erb with new input types
  • Add helper method to parse/serialize device selections
  • Update form specs in spec/system/agents/create_agent_spec.rb
  • Update page object spec/support/page_objects/agent_form_page.rb
  • Add validation in AdvancedConfiguration model if needed
  • Update API documentation in spec/swagger_helper.rb if format changes
  • Test edge cases (no devices selected, invalid values, etc.)

Related Files

  • app/views/agents/_form.html.erb - Main form view
  • app/models/advanced_configuration.rb - Configuration model
  • app/models/agent.rb - Agent model with devices array
  • spec/system/agents/create_agent_spec.rb - System tests
  • spec/support/page_objects/agent_form_page.rb - Test helpers

References

Hashcat OpenCL device types documentation showing the valid enumeration values.

Metadata

Metadata

Assignees

Labels

Projects

Status
Ready

Relationships

None yet

Development

No branches or pull requests

Issue actions