Skip to content

Commit

Permalink
feat(docs): Update custom detectors guide
Browse files Browse the repository at this point in the history
  • Loading branch information
jubnzv committed Nov 20, 2024
1 parent 4d99cfe commit da64cae
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions docs/hacking/custom-detector.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Detectors are designed to be dynamically loaded by the Misti driver, and they ar

## Creating a Detector

### Example implementation

You can create a new custom detector by executing Misti with the `--new-detector` option: `misti --new-detector implicitInit`.

This will create the `implicitInit.ts` file, which contains the template code for writing your own custom detector logic leveraging the Misti API.
Expand Down Expand Up @@ -46,8 +48,11 @@ export class ImplicitInit extends ASTDetector {

```

### Testing the detector
To run Misti with only your new detector, use the `--detectors` option, specifying the path to the detector and the Detector class name: `misti path/to/your/tact.config.json --detectors path/to/implicitInit.ts:ImplicitInit`.
### Running detector
To run Misti with only your new detector, use the `--enabled-detectors` (`-de`) option, specifying the path to the detector and the Detector class name:
```bash
misti path/to/src/contracts -de path/to/implicitInit.ts:ImplicitInit
```

That's a good way to test the detector on the first run. You could also use the `--verbose` CLI option and set the environment variable `MISTI_TRACE=1` to facilitate debugging.

Expand All @@ -62,7 +67,10 @@ After testing the detector, you can specify it in your configuration to enable i
}
```

After this, you could run Misti specifying a path to a custom configuration `misti --config path/to/misti.config.json path/to/your/tact.config.json`.
After this, you could run Misti specifying a path to a custom configuration which is less verbose when you have a few custom detectors:
```bash
misti --config path/to/misti.config.json path/src/contracts
```

## Example Detectors

Expand Down

0 comments on commit da64cae

Please sign in to comment.