Skip to content

Commit

Permalink
updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Yhtiyar committed Jul 31, 2023
1 parent c818a16 commit b42d3f7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
15 changes: 8 additions & 7 deletions docs/dubious_typecast.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# Dubious Typecast

## Configuration
* Check: `pess-dubious-typecast`
* Severity: `Low`
* Confidence: `Low`

- Check: `pess-dubious-typecast`
- Severity: `Medium`
- Confidence: `High`

## Description
Highlights unstandard typecasts.

### Potential Improvement
Reduce the number of FP removing the highlight of OK typecasts.
Highlights nonstandard typecasts. E.g: `uint256(uint8(K))`

## Vulnerable Scenario

[test scenario](../tests/dubious_typecast_test.sol)

## Recommendation
Makes contract logic more complex, which leads to an error probability increment. Use clean variables without typecasts.

Verify that the typecast doesn't break the code.
12 changes: 7 additions & 5 deletions slither_pess/detectors/dubious_typecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,20 @@ def is_ok_cast(from_type: str, to_type: str) -> bool:

class DubiousTypecast(AbstractDetector):
"""
Shows variables which are typecasted more than once.
Shows nonstandard typecasts.
"""

ARGUMENT = "pess-dubious-typecast" # slither will launch the detector with slither.py --detect mydetector
HELP = "uint8 = uint8(uint256)"
IMPACT = DetectorClassification.LOW
CONFIDENCE = DetectorClassification.LOW
IMPACT = DetectorClassification.MEDIUM
CONFIDENCE = DetectorClassification.HIGH

WIKI = "https://github.com/pessimistic-io/slitherin/blob/master/docs/dubious_typecast.md"
WIKI_TITLE = "Dubious Typecast"
WIKI_DESCRIPTION = "Constant variables should not be typecasted more than once"
WIKI_EXPLOIT_SCENARIO = "Makes contract logic more complex, wich leads to error probability increment and make integration more difficult"
WIKI_DESCRIPTION = "Check docs"
WIKI_EXPLOIT_SCENARIO = (
"Can produce unpredictable results because of nonstandard typecasts"
)
WIKI_RECOMMENDATION = "Use clear constants"

def analyze_irs(self, irs: List[Operation]) -> List[Tuple[str, str]]:
Expand Down

0 comments on commit b42d3f7

Please sign in to comment.