go-directequality-checker

command module
v0.0.0-...-f964c84 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2021 License: MIT Imports: 10 Imported by: 0

README

go-directequality-checker

go-directequality-checker is a small tool that performs static analysis of a Go package to identify places where direct equality comparisons of fields are done when it isn't appropriate to do so. This is particularly useful if you're wanting to ensure that certain fields are only compared using constant-time comparison for security reasons.

Installation

Installing it is as simple as running

go get github.com/1password/go-directequality-checker

Usage

In order to use this tool, you'll first need to annotate a struct field that you want to designate as not being allowed to do direct equality comparisons with a tag: security:"nodirectequality"

Example:

type User struct {
    VerificationToken string `db:"verification_token" security:"nodirectequality"`
}

Once you've annotated your field, you can run the tool via

go-directequality-checker path/to/go/package

If the tool finds any direct equality comparisons, it will output information about what it has found and recommend using a constant time comparison function (i.e. crypto/subtle's ConstantTimeCompare):

[SECURITY] Found raw comparison of field 'VerificationToken'. Use constant time comparison function.
/Users/rfillion/go/src/go.1password.io/b5/server/src/logic/action/transfer.go:106
user.VerificationToken == token {

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL