Manage YARA Rules
YARA rules are the backbone of custom detection in Stairwell. You can manage rules through the Stairwell UI or bulk-upload them using the Swell CLI. This page covers every rule management operation in one place.
Create a YARA Rule
Via the Stairwell UI
- Log in to Stairwell.
- Select the target Environment using the top-left environment selector.
- Click Rules in the sidebar navigation.
- Click + New Rule in the top-right area beneath the query bar.
- Write your YARA rule in the editor that appears on the right.
- (Optional) Test your rule before saving:
- Click Test Scan.
- Enter MD5, SHA-1, or SHA-256 hashes of files that should (or should not) match.
- Click Scan to validate the rule logic.
- Click Create to save the rule.
Via the Swell CLI
Use the upload command to bulk-import YARA rules into your environment.
Command:
./swell yara upload --environment_id <your_environment_id> <path>
Common flags:
| Flag | Description |
|---|---|
-f, --file <string> | Upload a .txt file containing a list of .yar file paths. |
-r, --recursive | Recursively scan all sub-folders for .yar files. |
--replace_existing_rules | Overwrite an existing rule that shares the same name. Without this flag, duplicates are rejected. |
--attempts <int> | Number of upload retry attempts (default: 5). |
--qps_limit <int> | Queries per second (default: 1). Higher values speed up uploads but increase host load. |
-h, --help | Display help for upload flags. |
Examples:
# Upload a single rule file
./swell yara upload --environment_id <id> "path/to/rule.yar"
# Upload and overwrite an existing rule with the same name
./swell yara upload --environment_id <id> --replace_existing_rules "path/to/rule.yar"
# Upload all rules in a folder
./swell yara upload --environment_id <id> "path/to/folder/"
# Recursively upload rules across nested folders
./swell yara upload -r --environment_id <id> "path/to/parent-folder/"Edit a YARA Rule
You can edit YARA rules that were created within your environment. Shared rules from other environments cannot be edited directly -- copy the rule body into a new custom rule first.
- Navigate to Rules and select the rule you want to edit.
- Open the rule in the half-pane view.
- Click the pencil icon to enter edit mode.
- Make your changes to the rule body.
- (Optional) Click Test Scan to validate. You can provide hashes of files that should and should not match, then review the results.
- Click Close on the test results when satisfied, then click Submit to save.
Note: The platform will return an error if you attempt to edit a shared rule from an environment you do not have write access to.
Enable or Disable a Rule
Toggling rules on or off lets you control detection coverage without permanently removing rule logic. Disabling a noisy rule reduces alert volume while preserving it for future use.
Single rule:
- Navigate to Rules and select the target rule.
- Use the toggle switch at the top-right of the rule body pane to enable or disable it.
Multiple rules at once:
- Select the checkboxes next to each rule you want to change.
- Click the three-dot menu at the top-right corner of the rule listing pane.
- Choose Enable or Disable.
Note: Inactive rules are hidden by default. Uncheck Hide inactive rules in the rules list to display them.
Delete a Rule
Deletion is permanent and cannot be undone. If you may need the rule logic later, consider disabling the rule instead.
Important: You can only delete rules created by your organization within your environment. Shared rules cannot be deleted.
Single rule:
- Navigate to Rules and select the rule you want to remove.
- Click the trash icon.
- Confirm the deletion when prompted.
Multiple rules at once:
- Select the checkboxes next to each rule you want to delete.
- Click the three-dot menu at the top-right corner of the rule listing pane.
- Choose Delete and confirm.
Search for a Rule
A consistent and intuitive naming convention for custom rules makes searching significantly easier.
- Navigate to Rules from the left sidebar.
- Enter a keyword in the Filter rules by keyword search field. By default, this searches across all active rules in all shared rule environments, including your own.
- (Optional) Uncheck Hide Inactive Rules to include disabled rules in the results.
- (Optional) Check or uncheck rule sets in the left panel to include or exclude specific collections.
- Select a rule to view its metadata and body.
Note: Due to licensing restrictions, certain rule sets (including Pro Rules) do not display the rule body.
Updated 4 days ago
