Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'gas' for security problems scanning #830

Merged
merged 2 commits into from May 18, 2018
Merged

Add 'gas' for security problems scanning #830

merged 2 commits into from May 18, 2018

Conversation

jpkrohling
Copy link
Contributor

@jpkrohling jpkrohling commented May 17, 2018

Signed-off-by: Juraci Paixão Kröhling juraci@kroehling.de

Which problem is this PR solving?

Short description of the changes

  • Added make gas
  • Annotated some of the issues to tell gas that those are OK
  • Removed unused code, flagged by gas

Others

  • I tried adding gometalinter and activate only gas, but got a different output, so, I think it might make sense to cherry-pick the linters and configure them individually
  • There's a make lint target, but doesn't seem to be used anywhere. And returns quite a bunch of messages :) So, I'm naming the env var LINT, but ignoring make lint for now. Hopefully, we'll use it later.

@coveralls
Copy link

coveralls commented May 17, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling 39f6164 on jpkrohling:455-Add-Go-AST into 9d05fad on jaegertracing:master.

@@ -59,7 +59,7 @@ func loadStrategies(strategiesFile string) (*strategies, error) {
if strategiesFile == "" {
return nil, nil
}
bytes, err := ioutil.ReadFile(strategiesFile)
bytes, err := ioutil.ReadFile(strategiesFile) /* nolint #nosec , this comes from an admin, not user */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this require linter directives?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The theory behind it is that strategiesFile can be manipulated by an end user, so that a file like /etc/shadow could be read. I tracked all instances of this case (G304, IIRC) and they all come from the CLI, meaning that they are set by an admin, and not by an end user.

.travis.yml Outdated
@@ -11,6 +11,7 @@ matrix:
env:
- TESTS=true
- COVERAGE=true
- LINT=true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the reason to separate this from the main make lint target? Does it run much slower?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, I thought make lint wasn't being used on purpose, because it fails with:

$ make lint
go vet ./cmd/... ./model/... ./pkg/... ./plugin/... ./crossdock/... ./storage/... .
cmd/query/app/static_handler_test.go:121: possible formatting directive in Error call
exit status 1
make: *** [Makefile:114: lint] Error 1

This failure does not show up in Travis though. I just changed this PR to fix the lint failure above and to get make lint to also call the target gas

Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
@@ -128,6 +133,10 @@ install-go-bindata:
go get github.com/jteeuwen/go-bindata/...
go get github.com/elazarl/go-bindata-assetfs/...

.PHONY: install-gas
install-gas:
go get github.com/GoASTScanner/gas/cmd/gas/...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still not clear why we need the extra makefile targets instead of rolling it up into the main install and lint (extra targets increase noise / entropy)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

install is quite clean, doing only a glide install. It does delegate the installation of the dependent tool (glide) to a separate target, so, there's a precedent :-)

About gas getting called directly from lint, I guess it's a matter of taste. When working on fixing the warnings provided by gas, I find it easier to run it in isolation as make gas.

@ghost ghost assigned yurishkuro May 18, 2018
@yurishkuro yurishkuro merged commit 5f4014e into jaegertracing:master May 18, 2018
@ghost ghost removed the review label May 18, 2018
mabn pushed a commit to mabn/jaeger that referenced this pull request May 28, 2018
* master: (38 commits)
  Preparing release 1.5.0 (jaegertracing#847)
  Add bounds to memory storage (jaegertracing#845)
  Add metric for debug traces (jaegertracing#796)
  Change metrics naming scheme (jaegertracing#776)
  Bump gocql version (jaegertracing#829)
  Remove ParentSpanID from domain model (jaegertracing#831)
  Make gas run quiet (jaegertracing#838)
  Revert "Make gas run quite"
  Revert "Install gas from install-ci"
  Install gas from install-ci
  Make gas run quite
  Add 'gas' for security problems scanning (jaegertracing#830)
  Add ability to adjust static sampling probabilities per operation (jaegertracing#827)
  Support log-level flag on agent (jaegertracing#828)
  Remove unused function (jaegertracing#822)
  Add healthcheck to standalone (jaegertracing#784)
  Do not use KeyValue fields directly and use KeyValues as decorator only (jaegertracing#810)
  Add ContaAzul to the adopters list (jaegertracing#806)
  Add ISSUE_TEMPLATE and PULL_REQUEST_TEMPLATE (jaegertracing#805)
  Upgrade to  go 1.10 (jaegertracing#792)
  ...

# Conflicts:
#	cmd/agent/app/builder.go
#	cmd/collector/main.go
#	cmd/query/main.go
#	cmd/standalone/main.go
@jpkrohling jpkrohling deleted the 455-Add-Go-AST branch July 28, 2021 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adopt static code analysis with security verification
4 participants