-
Notifications
You must be signed in to change notification settings - Fork 24
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
Fix static analysis issues #480
Merged
MatheusFranco99
merged 6 commits into
ssvlabs:dev
from
MFrancoLink:static-analysis-issues
Aug 20, 2024
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d7b1626
Solve potential file inclusion via variable
MatheusFranco99 e1fd5a8
Fix file permission (0644 to 0600)
MatheusFranco99 e41fc27
Add nosec comment for PRNG (pseudo-random number generator) used for …
MatheusFranco99 38e4009
Fix lint issue on nil check in []byte type
MatheusFranco99 5fe77f7
Update permission from 0444 to 0600
MatheusFranco99 07f8940
Update 0444 to 0400
MatheusFranco99 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,16 +3,17 @@ package main | |
import ( | ||
"encoding/json" | ||
"fmt" | ||
"github.com/pkg/errors" | ||
"github.com/ssvlabs/ssv-spec/qbft/spectest/tests" | ||
comparable2 "github.com/ssvlabs/ssv-spec/types/testingutils/comparable" | ||
"log" | ||
"os" | ||
"path/filepath" | ||
"reflect" | ||
"runtime" | ||
"strings" | ||
|
||
"github.com/pkg/errors" | ||
"github.com/ssvlabs/ssv-spec/qbft/spectest/tests" | ||
comparable2 "github.com/ssvlabs/ssv-spec/types/testingutils/comparable" | ||
|
||
"github.com/ssvlabs/ssv-spec/qbft/spectest" | ||
) | ||
|
||
|
@@ -92,7 +93,7 @@ func writeJsonStateComparison(name, testType string, post interface{}) { | |
|
||
file := filepath.Join(scDir, fmt.Sprintf("%s.json", name)) | ||
log.Printf("writing state comparison json: %s\n", file) | ||
if err := os.WriteFile(file, byts, 0644); err != nil { | ||
if err := os.WriteFile(file, byts, 0600); err != nil { | ||
panic(err.Error()) | ||
} | ||
} | ||
|
@@ -119,7 +120,7 @@ func writeJson(data []byte) { | |
|
||
file := filepath.Join(basedir, "tests.json") | ||
log.Printf("writing spec tests json to: %s\n", file) | ||
if err := os.WriteFile(file, data, 0644); err != nil { | ||
if err := os.WriteFile(file, data, 0600); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
panic(err.Error()) | ||
} | ||
} |
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
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
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.
I would update to 0444
The reason is that we don't want anyone writing to the file, to make tests pass/fail.
There's nothing confidential here so might as well let everyone read
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.
Yup, I agree
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.
Actually,
gosec
still complains about 0444:Can't it be 0400? Why do we need to allow "read" for group and others?
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.
hmm
if CI passes then it can be 0400 honestly
I just think that there is no confidential information and the SSV repo generate jsons itself.
I just saw no sec concern so you can choose
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.
I also don't see security concerns, but
gosec
complains and I also don't see a reason for the group and others read permission.Updating it to 0400