Skip to content

Commit

Permalink
Added Toggle detections on and off documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
matiascabello committed Aug 31, 2024
1 parent 9d8f07d commit be40466
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 8 deletions.
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,19 @@ Join us for an exciting series of video tutorials where you'll learn how to inst
- [Introduction to Scout](https://www.youtube.com/watch?v=L4kGwPDuWgA)
- [Installing Scout](https://www.youtube.com/watch?v=lStQxKQ_l2Q&t=1s)
- [How to run Scout](https://www.youtube.com/watch?v=_6F24AwscKc)
- [Detecting and fixing issues: Divide before multiply](https://www.youtube.com/watch?v=aLtXyYvw27o)
- [Detecting and fixing issues: Incorrect exponentiation](https://www.youtube.com/watch?v=qjnHwKCD_hM)
- [Detecting and fixing issues: Overflow check](https://www.youtube.com/watch?v=Mi7AcJRPgvU)
- [Detecting and fixing issues: Insufficiently random values](https://www.youtube.com/watch?v=LPBMDPXmczQ)
- [Detecting and fixing issues: DoS - Unexpected revert with vector](https://www.youtube.com/watch?v=H79mMnnWyvA)
- [Detecting and fixing issues: DoS - Unbounded operation](https://www.youtube.com/watch?v=DFM0yNNDiyw)
- [Detecting and fixing issues: Set contract storage](https://www.youtube.com/watch?v=z6RNfhQt6EI)
- [Learning to Scout Soroban: Divide before multiply](https://www.youtube.com/watch?v=aLtXyYvw27o)
- [Learning to Scout Soroban: Incorrect exponentiation](https://www.youtube.com/watch?v=qjnHwKCD_hM)
- [Learning to Scout Soroban: Overflow check](https://www.youtube.com/watch?v=Mi7AcJRPgvU)
- [Learning to Scout Soroban: Insufficiently random values](https://www.youtube.com/watch?v=LPBMDPXmczQ)
- [Learning to Scout Soroban: DoS - Unexpected revert with vector](https://www.youtube.com/watch?v=H79mMnnWyvA)
- [Learning to Scout Soroban: DoS - Unbounded operation](https://www.youtube.com/watch?v=DFM0yNNDiyw)
- [Learning to Scout Soroban: Set contract storage](https://www.youtube.com/watch?v=z6RNfhQt6EI)
- [Learning to Scout Soroban: Unprotected mapping operation](https://www.youtube.com/watch?v=8yayEpKeles)
- [Learning to Scout Soroban: Unprotected update current contract wasm](https://www.youtube.com/watch?v=05WnTt4gw5o)
- [Learning to Scout Soroban: Unrestricted transfer from](https://www.youtube.com/watch?v=jnorbpq3ZXk)
- [Learning to Scout Soroban: Assert violation](https://www.youtube.com/watch?v=-8iv4qXjx-M)
- [Learning to Scout Soroban: Iterators over indexing](https://www.youtube.com/watch?v=PN7sD-W0_Qg)
- [Learning to Scout Soroban: Unsafe expect](https://www.youtube.com/watch?v=sheqaOBOBfo)

:clapper: More videos comming soon!

Expand Down Expand Up @@ -139,6 +145,7 @@ Follow our documentation links below and learn more about the vulnerabilities de
- [Scout GitHub Action](https://coinfabrik.github.io/scout-soroban/docs/github-action)
- [Scout VS Code Extension](https://coinfabrik.github.io/scout-soroban/docs/vscode-extension)
- [Scout Soroban Examples](https://coinfabrik.github.io/scout-soroban/docs/soroban-examples)
- [Toggle detections on and off](https://coinfabrik.github.io/scout-soroban/docs/toggle-detections-on-off)

## Acknowledgements

Expand Down
64 changes: 64 additions & 0 deletions docs/docs/toggle-detections-on-off.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
sidebar_position: 10
---

# Toggle detections on and off

In addition to enabling and disabling detectors, Scout allows users to toggle individual detections on or off. This feature is useful for disabling detections that are false positives or not relevant to the analyzed codebase.

## Usage

### 1) Import scout-utils package

To use the toggle detections on/off feature, you’ll need to import the `scout-utils` package into your project, adding the following line to your `Cargo.toml`.

```rust
scout-utils = "0.1.0"
```

### 2) Include scout-utils in your Rust file

Include the scout-utils package in the Rust file in which you want to disable detections, adding the following line:

```rust
use scout-audit::scout_allow;
```

### 3) Use scout_allow macro to disable a detection

To disable a detection, you’ll need to use the scout_allow macro, with the name of the detection to disable as an attribute. For example:

```rust
#[scout_allow(unsafe_unwrap)]
```

Place the macro before the block of code in which you want to disable a detection. For example:

```rust
#[scout_allow(unsafe_expect)]
pub fn my_func() {
let x: Option<&str> = None;
x.expect("Something went wrong!");
}
```

The macro supports including more than one attribute to disable multiple detections at once. For example:

```rust
#[scout_allow(unsafe_unwrap, integer_overflow_or_underflow)]
```

## Supported scope

`scout_allow` macro supports disabling detections for the following scopes:

- Functions (entire body)
- Modules
- Structs
- Enums
- Traits
- Impl blocks

## Unnecesary scout_allow macro detector

If Scout Audit detects a scout_allow macro for a block of code in which the disallowed detection is not triggered, it will raise a warning.
1 change: 0 additions & 1 deletion docs/docs/vscode-extension.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ Add Scout to your development workspace with Scout's VS Code extension and run S
:bulb: Tip: To see the errors highlighted in your code, we recommend installing the [Error Lens Extension](https://marketplace.visualstudio.com/items?itemName=usernamehw.errorlens).

:point_right: Download Scout VS Code from [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=CoinFabrik.scout-audit).

0 comments on commit be40466

Please sign in to comment.