Skip to content

Details ‐ Settings

Michael Haag edited this page Jul 23, 2024 · 1 revision

Settings Page Documentation

The Settings page in ShellSweepX provides a user interface for configuring various aspects of the system, including API keys, AI prompts, YARA rules management, and database scanning. This page allows administrators to customize the behavior and capabilities of ShellSweepX.

Page Structure

The settings.html template is structured as follows:

  1. Header: Contains the ShellSweepX logo and navigation menu.
  2. Main Content:
    • Settings Form
    • YARA Rules Management
    • Database Scan Button
    • Rule Viewer/Editor
  3. Footer: Displays copyright information and a link to Terms of Service.

Key Features

1. Settings Form

  • Allows configuration of:
    • GPT API Key
    • Claude API Key
    • AI Prompt
    • YARA Enablement
  • Form submission saves settings via POST to /save_settings
  • Displays success/error messages after form submission

2. YARA Rules Management

  • Lists existing YARA rules with validation status
  • Provides options to view, edit, and delete individual rules
  • Allows adding new YARA rules

3. Database Scan

  • Button to trigger a scan of the database using current YARA rules

4. Rule Viewer/Editor

  • Modal-like interface for viewing, editing, and adding YARA rules
  • Dynamically shows/hides based on user actions

JavaScript Functionality

The page includes several JavaScript functions to handle dynamic behavior:

  1. viewRule(filename, content): Displays the rule viewer with the selected rule's content
  2. closeViewer(): Hides the rule viewer
  3. addNewRule(): Prepares the rule viewer for adding a new rule
  4. saveRule(): Handles saving new or updated rules
  5. deleteRule(filename): Manages the deletion of YARA rules
  6. Event listeners for various user interactions (e.g., clicking view/delete buttons, saving rules)

AJAX Interactions

The page uses fetch API for asynchronous interactions with the server:

  1. Scanning database with YARA rules
  2. Adding new YARA rules
  3. Updating existing YARA rules
  4. Deleting YARA rules

Styling

  • Uses CSS defined in /static/css/styles.css
  • Custom styling for form elements, buttons, and the rule viewer

User Experience Considerations

  1. Visual Feedback: Uses checkmarks to indicate set API keys and YARA rule validity
  2. Confirmation Dialogs: Asks for confirmation before deleting rules
  3. Dynamic Updates: Page reloads after rule changes to reflect current state
  4. Modal-like Editing: Rule viewer appears over the main content for focused editing

Security Considerations

  1. API keys are input as password fields to mask the values
  2. YARA rule content is properly escaped to prevent XSS attacks
  3. Server-side validation (implied) for API key and YARA rule changes

Potential Enhancements

  1. Real-time Validation: Validate YARA rules in real-time as they're being edited
  2. Pagination: If the number of YARA rules grows large, implement pagination for the rules list
  3. Search Functionality: Add ability to search through YARA rules
  4. Rule Categories: Implement a categorization system for YARA rules
  5. Backup/Restore: Add functionality to backup and restore settings and YARA rules

Integration with Backend

  • The template uses Jinja2 syntax to populate initial values (e.g., {{ settings.gpt_api_key }})
  • Form submission and AJAX calls interact with various backend endpoints for data management

This Settings page serves as a crucial interface for administrators to configure and maintain the ShellSweepX system. It provides comprehensive control over API integrations, AI behavior, and YARA rule management, allowing for fine-tuned customization of the webshell detection process.