-
Notifications
You must be signed in to change notification settings - Fork 20.1k
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
cmd/geth: implement vulnerability check #21859
Merged
Merged
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
99d756f
cmd/geth: implement vulnerability check
holiman bc68c30
cmd/geth: use minisign to verify vulnerability feed
holiman 765eb3f
cmd/geth: add the test too
holiman 079e23e
cmd/geth: more minisig/signify testing
holiman ae00c56
cmd/geth: support multiple pubfiles for signing
holiman 7a25129
cmd/geth: add @holiman minisig pubkey
holiman f546792
cmd/geth: polishes on vulnerability check
holiman 6bebea9
cmd/geth: fix ineffassign linter nit
holiman e2f70f0
cmd/geth: add CVE to version check struct
holiman a3220d7
cmd/geth/testdata: add missing testfile
holiman f0ffd83
cmd/geth: add more keys to versionchecker
holiman 1d59c52
cmd/geth: support file:// URLs in version check
fjl 5114323
cmd/geth: improve key ID printing when signature check fails
fjl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// Copyright 2020 The go-ethereum Authors | ||
// This file is part of go-ethereum. | ||
// | ||
// go-ethereum is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// go-ethereum is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"github.com/ethereum/go-ethereum/log" | ||
"github.com/ethereum/go-ethereum/params" | ||
"gopkg.in/urfave/cli.v1" | ||
"io/ioutil" | ||
"net/http" | ||
"regexp" | ||
"runtime" | ||
) | ||
|
||
const versionFeed = "https://geth.ethereum.org/docs/vulnerabilities/vulnerabilities.json" | ||
|
||
type vulnJson struct { | ||
Name string | ||
Uid string | ||
Summary string | ||
Description string | ||
Links []string | ||
Introduced string | ||
Fixed string | ||
Published string | ||
Severity string | ||
Check string | ||
} | ||
|
||
func versionCheck(ctx *cli.Context) error { | ||
args := ctx.Args() | ||
version := fmt.Sprintf("Geth/v%v/%v-%v/%v", | ||
params.VersionWithCommit(gitCommit, gitDate), | ||
runtime.GOOS, | ||
runtime.GOARCH, | ||
runtime.Version()) | ||
if len(args) > 0 { | ||
// Explicit version string given | ||
version = args[0] | ||
} | ||
log.Info("Checking vulnerabilities", "version", version) | ||
return checkCurrent(version) | ||
} | ||
|
||
func checkCurrent(current string) error { | ||
res, err := http.Get(versionFeed) | ||
if err != nil { | ||
return err | ||
} | ||
defer res.Body.Close() | ||
body, err := ioutil.ReadAll(res.Body) | ||
if err != nil { | ||
return err | ||
} | ||
var vulns []vulnJson | ||
if err = json.Unmarshal(body, &vulns); err != nil { | ||
return err | ||
} | ||
for _, vuln := range vulns { | ||
r, err := regexp.Compile(vuln.Check) | ||
fjl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if err != nil { | ||
return err | ||
} | ||
if r.MatchString(current) { | ||
fmt.Printf("## Vulnerable to %v (%v)\n\n", vuln.Uid, vuln.Name) | ||
fmt.Printf("Severity: %v\n", vuln.Severity) | ||
fmt.Printf("Summary : %v\n", vuln.Summary) | ||
fmt.Printf("Fixed in: %v\n", vuln.Fixed) | ||
if len(vuln.Links) > 0 { | ||
fmt.Printf("References:\n") | ||
for _, ref := range vuln.Links { | ||
fmt.Printf("\t- %v\n", ref) | ||
} | ||
} | ||
fmt.Println() | ||
} | ||
} | ||
return nil | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any signature we can verify the JSON we get is correct?