Skip to content

Commit

Permalink
feat(docs): Add ExitCodeUsage
Browse files Browse the repository at this point in the history
  • Loading branch information
jubnzv committed Nov 8, 2024
1 parent cc117a0 commit 34e6288
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 18 deletions.
35 changes: 18 additions & 17 deletions docs/detectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,24 @@ title: Detectors Overview
| 8 | [DuplicatedCondition](./detectors/DuplicatedCondition.md) | High | ||
| 9 | [EnsurePrgSeed](./detectors/EnsurePrgSeed.md) | Medium | ||
| 10 | [EtaLikeSimplifications](./detectors/EtaLikeSimplifications.md) | Low | ||
| 11 | [FalseCondition](./detectors/FalseCondition.md) | Medium | ||
| 12 | [FieldDoubleInit](./detectors/FieldDoubleInit.md) | Medium | ||
| 13 | [InheritedStateMutation](./detectors/InheritedStateMutation.md) | Low | | |
| 14 | [NeverAccessedVariables](./detectors/NeverAccessedVariables.md) | Medium | ||
| 15 | [OptimalMathFunction](./detectors/OptimalMathFunction.md) | Low | ||
| 16 | [PreferAugmentedAssign](./detectors/PreferAugmentedAssign.md) | Info | ||
| 17 | [PreferredStdlibApi](./detectors/PreferredStdlibApi.md) | Info | | |
| 18 | [ReadOnlyVariables](./detectors/ReadOnlyVariables.md) | Medium |||
| 19 | [SendInLoop](./detectors/SendInLoop.md) | Medium | | |
| 20 | [ShortCircuitCondition](./detectors/ShortCircuitCondition.md) | Low | ||
| 21 | [StringReceiversOverlap](./detectors/StringReceiversOverlap.md) | High | ||
| 22 | [SuspiciousMessageMode](./detectors/SuspiciousMessageMode.md) | Medium | ||
| 23 | [UnboundLoop](./detectors/UnboundLoop.md) | High |||
| 24 | [UnboundMap](./detectors/UnboundMap.md) | Low | | |
| 25 | [UnusedExpressionResult](./detectors/UnusedExpressionResult.md) | Medium | ||
| 26 | [UnusedOptional](./detectors/UnusedOptional.md) | Low | ||
| 27 | [ZeroAddress](./detectors/ZeroAddress.md) | Low | ||
| 11 | [ExitCodeUsage](./detectors/ExitCodeUsage.md) | High | ||
| 12 | [FalseCondition](./detectors/FalseCondition.md) | Medium | ||
| 13 | [FieldDoubleInit](./detectors/FieldDoubleInit.md) | Medium | ||
| 14 | [InheritedStateMutation](./detectors/InheritedStateMutation.md) | Low | | |
| 15 | [NeverAccessedVariables](./detectors/NeverAccessedVariables.md) | Medium | ||
| 16 | [OptimalMathFunction](./detectors/OptimalMathFunction.md) | Low | ||
| 17 | [PreferAugmentedAssign](./detectors/PreferAugmentedAssign.md) | Info | ||
| 18 | [PreferredStdlibApi](./detectors/PreferredStdlibApi.md) | Info | | |
| 19 | [ReadOnlyVariables](./detectors/ReadOnlyVariables.md) | Medium |||
| 20 | [SendInLoop](./detectors/SendInLoop.md) | Medium | | |
| 21 | [ShortCircuitCondition](./detectors/ShortCircuitCondition.md) | Low | ||
| 22 | [StringReceiversOverlap](./detectors/StringReceiversOverlap.md) | High | ||
| 23 | [SuspiciousMessageMode](./detectors/SuspiciousMessageMode.md) | Medium | ||
| 24 | [UnboundLoop](./detectors/UnboundLoop.md) | High |||
| 25 | [UnboundMap](./detectors/UnboundMap.md) | Low | | |
| 26 | [UnusedExpressionResult](./detectors/UnusedExpressionResult.md) | Medium | ||
| 27 | [UnusedOptional](./detectors/UnusedOptional.md) | Low | ||
| 28 | [ZeroAddress](./detectors/ZeroAddress.md) | Low | ||

Some of the detectors require [Soufflé](https://souffle-lang.github.io/install) to be installed. If no Soufflé installation is found, these detectors won't be executed.

Expand Down
37 changes: 37 additions & 0 deletions docs/detectors/ExitCodeUsage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# ExitCodeUsage
A detector that identifies improper use of exit codes outside the developer-allowed range.

## Why is it bad?
In the TON blockchain, exit codes are divided into specific ranges: 0 to 127
are reserved for the TVM or FunC, and 128 to 255 are reserved for Tact. This
structure leaves the range from 256 to 65535 for developers to define custom
exit codes.

When exit codes are defined outside this allowed range, it may lead to
conflicts with existing reserved codes, causing unintended behavior or
errors in the contract.

## Example
```tact
contract Foo {
receive("foobar") {
// Bad: exit code defined in the reserved range for Tact
let code: Int = 128;
nativeThrowUnless(code, sender() == self.owner);
}
}
```

Use instead:
```tact
contract Foo {
receive("foobar") {
// OK: using exit code from the allowed range
let code: Int = 256;
nativeThrowUnless(code, sender() == self.owner);
}
}
```

## Resources
1. [Exit Codes | Tact Docs](https://docs.tact-lang.org/book/exit-codes)
5 changes: 5 additions & 0 deletions sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ const sidebars: SidebarsConfig = {
id: 'detectors/EtaLikeSimplifications',
label: 'EtaLikeSimplifications',
},
{
type: 'doc',
id: 'detectors/ExitCodeUsage',
label: 'ExitCodeUsage',
},
{
type: 'doc',
id: 'detectors/FalseCondition',
Expand Down
2 changes: 1 addition & 1 deletion src/pages/tools/misti/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default function Home() {
<div className="container">
<h2 className={styles.featuresTitle}>Discover Detectors</h2>
<p className={styles.featuresSummary}>
Misti supports 27 specialized detectors designed to identify code issues, detect vulnerabilities, and enforce best practices.
Misti supports 28 specialized detectors designed to identify code issues, detect vulnerabilities, and enforce best practices.
</p>

<div className={`${styles.rowWithMargin} row`}>
Expand Down

0 comments on commit 34e6288

Please sign in to comment.