All Projects → tommy-muehle → go-mnd

tommy-muehle / go-mnd

Licence: MIT license
Magic number detector for Go.

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects
Dockerfile
14818 projects
shell
77523 projects

Projects that are alternatives of or similar to go-mnd

Phpmnd
PHP Magic Number Detector
Stars: ✭ 431 (+181.7%)
Mutual labels:  analysis, static-analysis, detector
Sonar Java
☕️ SonarSource Static Analyzer for Java Code Quality and Security
Stars: ✭ 745 (+386.93%)
Mutual labels:  analysis, static-analysis
Phan
Phan is a static analyzer for PHP. Phan prefers to avoid false-positives and attempts to prove incorrectness rather than correctness.
Stars: ✭ 5,194 (+3294.77%)
Mutual labels:  analysis, static-analysis
Analyzer
🔍 Offline Analyzer for extracting features, artifacts and IoCs from Windows, Linux, Android, iPhone, Blackberry, macOS binaries, emails and more
Stars: ✭ 108 (-29.41%)
Mutual labels:  analysis, static-analysis
Binee
Binee: binary emulation environment
Stars: ✭ 408 (+166.67%)
Mutual labels:  analysis, static-analysis
Security Code Scan
Vulnerability Patterns Detector for C# and VB.NET
Stars: ✭ 550 (+259.48%)
Mutual labels:  analysis, static-analysis
Codechecker
CodeChecker is an analyzer tooling, defect database and viewer extension for the Clang Static Analyzer and Clang Tidy
Stars: ✭ 1,209 (+690.2%)
Mutual labels:  analysis, static-analysis
Horusec
Horusec is an open source tool that improves identification of vulnerabilities in your project with just one command.
Stars: ✭ 311 (+103.27%)
Mutual labels:  analysis, static-analysis
Dg
[LLVM Static Slicer] Various program analyses, construction of dependence graphs and program slicing of LLVM bitcode.
Stars: ✭ 242 (+58.17%)
Mutual labels:  analysis, static-analysis
SDA
SDA is a rich cross-platform tool for reverse engineering that focused firstly on analysis of computer games. I'm trying to create a mix of the Ghidra, Cheat Engine and x64dbg. My tool will combine static and dynamic analysis of programs. Now SDA is being developed.
Stars: ✭ 98 (-35.95%)
Mutual labels:  analysis, static-analysis
sbt-findbugs
FindBugs static analysis plugin for sbt.
Stars: ✭ 47 (-69.28%)
Mutual labels:  analysis, static-analysis
Go Ruleguard
Define and run pattern-based custom linting rules.
Stars: ✭ 402 (+162.75%)
Mutual labels:  analysis, static-analysis
Detekt
Static code analysis for Kotlin
Stars: ✭ 4,169 (+2624.84%)
Mutual labels:  analysis, static-analysis
Exakat
The Exakat Engine : smart static analysis for PHP
Stars: ✭ 346 (+126.14%)
Mutual labels:  analysis, static-analysis
lints
Lint all your JavaScript, CSS, HTML, Markdown and Dockerfiles with a single command
Stars: ✭ 14 (-90.85%)
Mutual labels:  analysis, static-analysis
Structured Acceptance Test
An open format definition for static analysis tools
Stars: ✭ 10 (-93.46%)
Mutual labels:  analysis, static-analysis
Krane
Kubernetes RBAC static Analysis & visualisation tool
Stars: ✭ 254 (+66.01%)
Mutual labels:  analysis, static-analysis
Chronos
Chronos - A static race detector for the go language
Stars: ✭ 272 (+77.78%)
Mutual labels:  analysis, static-analysis
Zpa
A parser and source code analyzer for PL/SQL and Oracle SQL.
Stars: ✭ 124 (-18.95%)
Mutual labels:  analysis, static-analysis
swap-detector
A library for detecting swapped arguments in function calls, and a Clang Static Analyzer plugin used to demonstrate the library.
Stars: ✭ 19 (-87.58%)
Mutual labels:  analysis, static-analysis

go-mnd - Magic number detector for Golang

A vet analyzer to detect magic numbers.

What is a magic number?
A magic number is a numeric literal that is not defined as a constant, but which may change, and therefore can be hard to update. It's considered a bad programming practice to use numbers directly in any source code without an explanation. It makes programs harder to read, understand, and maintain.

Project status

CI Go Report Card codecov

Install

Local

This analyzer requires Golang in version >= 1.12 because it's depends on the go/analysis API.

go get -u github.com/tommy-muehle/go-mnd/v2/cmd/mnd

Github action

You can run go-mnd as a GitHub action as follows:

name: Example workflow
on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master
jobs:
  tests:
    runs-on: ubuntu-latest
    env:
      GO111MODULE: on
    steps:
      - name: Checkout Source
        uses: actions/checkout@v2
      - name: Run go-mnd
        uses: tommy-muehle/go-mnd@master
        with:
          args: ./...

GitLab CI

You can run go-mnd inside a GitLab CI pipeline as follows:

stages:
  - lint

go:lint:mnd:
  stage: lint
  needs: []
  image: golang:latest
  before_script:
    - go get -u github.com/tommy-muehle/go-mnd/v2/cmd/mnd
    - go mod tidy
    - go mod vendor
  script:
    - go vet -vettool $(which mnd) ./...

Homebrew

To install with Homebrew, run:

brew tap tommy-muehle/tap && brew install tommy-muehle/tap/mnd

Docker

To get the latest available Docker image:

docker pull tommymuehle/go-mnd

Windows

On Windows download the latest release.

Usage

asciicast

go vet -vettool $(which mnd) ./...

or directly

mnd ./...

or via Docker

docker run --rm -v "$PWD":/app -w /app tommymuehle/go-mnd:latest ./...

Options

The -checks option let's you define a comma separated list of checks.

The -ignored-numbers option let's you define a comma separated list of numbers to ignore.
For example: -ignored-numbers=1000,10_000,3.14159264

The -ignored-functions option let's you define a comma separated list of function name regexp patterns to exclude.
For example: -ignored-functions=math.*,http.StatusText,make

The -ignored-files option let's you define a comma separated list of filename regexp patterns to exclude.
For example: -ignored-files=magic_.*.go,.*_numbers.go

Checks

By default this detector analyses arguments, assigns, cases, conditions, operations and return statements.

  • argument
t := http.StatusText(200)
  • assign
c := &http.Client{
    Timeout: 5 * time.Second,
}
  • case
switch x {
    case 3:
}
  • condition
if x > 7 {
}
  • operation
var x, y int
y = 10 * x
  • return
return 3

Excludes

By default the numbers 0 and 1 as well as test files are excluded!

Further known excludes

The function "Date" in the "Time" package.

t := time.Date(2017, time.September, 26, 12, 13, 14, 0, time.UTC)

Additional custom excludes can be defined via option flag.

Development

Build

You can build the binary with:

make

Tests

You can run all unit tests using:

make test

And with coverage report:

make test-coverage

Docker image

You can also build locally the docker image by using the command:

make image

Stickers

Stickers image Sticker image

Just drop me a message via Twitter DM or email if you want some go-mnd stickers for you or your Gopher usergroup.

License

The MIT License (MIT). Please see LICENSE for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].