Skip to main content

Clarity Static Analyzer

Project description

Tests passing

STACY - Stacks Static Analyzer for Clarity

Stacy is an open-source static analyzer for Clarity smart contracts. It is intended to assist Clarity smart contract developers and auditors detect common security issues and deviations from best practices.

This tool will help developers write secure and more robust smart contracts.

Install

HTTPS

git clone --recurse-submodules -j8 https://github.com/CoinFabrik/stacy.git
cd stacy
make

SSH

git clone --recurse-submodules -j8 git@github.com:CoinFabrik/stacy.git
cd stacy
make

If you already have an initialized python venv, use make install

If you have a shell other than bash, use make <shell>

Run

stacy-analyzer lint <path/to/.clar>

You can run recursively over all .clar files in a directory. For this, run

stacy-analyzer lint <path/to/contract/folder>

Tests

To run tests, run

make test

Common issues

tree-sitter-clar installation fails

If the installation of tree-sitter-clar fails, go into stacks_analyzer/tree-sitter-clarity and run

tree-sitter generate && tree-sitter-build

Ensure that the submodule is loaded.

Documentation

Detectors

Severities are based on worst case scenarios and the detector's finding may vary depending on the context.

Detector ID What it Detects Test Cases Severity
assert-block-height Usage of block-height as time tracker. 1 Critical
call-inside-as-contract Calling another contract losing the first contract's context. 1 Critical
divide-before-multiply Performing a division operation before a multiplication, leading to loss of precision. 1 Critical
private-function-not-used Dead code(private functions) inside the smart contract. 1 Enhancement
todo-comment TODO comments left in the smart contract. 1 Enhancement
tx-sender-in-assert Usage of tx-sender in assert is truly intended. 1 High
unwrap-panic-usage Inappropriate usage of the unwrap-panic method, causing unexpected program crashes. 1 Enhancement
var-could-be-constant Code that does not change and could be re-define. 1 Enhancement
updated-functions Old functions. 1 Enhancement
tx-sender-in-assert Usage of tx-sender in assert is truly intended. 1 High
unwrap-panic-usage Inappropriate usage of the unwrap-panic method, causing unexpected program crashes. 1 Enhancement
var-could-be-constant Code that does not change and could be re-define. 1 Enhancement

About CoinFabrik

We - CoinFabrik - are a research and development company specialized in Web3, with a strong background in cybersecurity. Founded in 2014, we have worked on over 180 blockchain-related projects, EVM based and also for Solana, Algorand, and Polkadot. Beyond development, we offer security audits through a dedicated in-house team of senior cybersecurity professionals, currently working on code in Substrate, Solidity, Clarity, Rust, and TEAL.

Our team has an academic background in computer science and mathematics, with work experience focused on cybersecurity and software development, including academic publications, patents turned into products, and conference presentations. Furthermore, we have an ongoing collaboration on knowledge transfer and open-source projects with the University of Buenos Aires.

License

Stacy is licensed and distributed under a MIT license. Contact us if you're looking for an exception to the terms.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stacy_analyzer-0.1.0.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stacy_analyzer-0.1.0-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file stacy_analyzer-0.1.0.tar.gz.

File metadata

  • Download URL: stacy_analyzer-0.1.0.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for stacy_analyzer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1b4cfacbe6df964e97a223a757eeb489ae7f2a648cb813709506d99ffbb420f3
MD5 2849b2868c2eba4c8c85bb0afbc4a52b
BLAKE2b-256 be340c4c4bd61d671bf3fad8805adffe13b278dd13268067834ec39f344bbcf4

See more details on using hashes here.

File details

Details for the file stacy_analyzer-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: stacy_analyzer-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for stacy_analyzer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dc0915f628220e9f538c447c5d026b6195e04d9a83ee7d288387bb5e0dfe9fce
MD5 3cb3b05c4d899b9dec6c31080024bbd7
BLAKE2b-256 38380f2853dab3337f1ddf16dfd9291fd3280cfd12d78059758b4fe5d1ceaaa6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page