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

enable gosec #147

Merged
merged 8 commits into from
Oct 3, 2022
Merged

enable gosec #147

merged 8 commits into from
Oct 3, 2022

Conversation

kim-tsao
Copy link
Contributor

Signed-off-by: Kim Tsao ktsao@redhat.com

What does this PR do?:

  • enables gosec in githubs actions, we will not fail if there are scan findings
  • adds rule to Makefile
  • clean up other rules in Makefile

Which issue(s) this PR fixes:

devfile/api#937

PR acceptance criteria:

Testing and documentation do not need to be complete in order for this PR to be approved. We just need to ensure tracking issues are opened.

  • Open new test/doc issues under the devfile/api repo
  • Check each criteria if:
  • There is a separate tracking issue. Add the issue link under the criteria
    or
  • test/doc updates are made as part of this PR
  • If unchecked, explain why it's not needed

How to test changes / Special notes to the reviewer:

Signed-off-by: Kim Tsao <ktsao@redhat.com>
Signed-off-by: Kim Tsao <ktsao@redhat.com>
@codecov-commenter
Copy link

codecov-commenter commented Sep 21, 2022

Codecov Report

Base: 58.23% // Head: 58.20% // Decreases project coverage by -0.02% ⚠️

Coverage data is based on head (0aaa518) compared to base (4c7c5dc).
Patch coverage: 42.85% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #147      +/-   ##
==========================================
- Coverage   58.23%   58.20%   -0.03%     
==========================================
  Files          35       35              
  Lines        3963     3965       +2     
==========================================
  Hits         2308     2308              
- Misses       1516     1518       +2     
  Partials      139      139              
Impacted Files Coverage Δ
pkg/devfile/parser/configurables.go 0.00% <0.00%> (ø)
pkg/devfile/parser/parse.go 53.88% <0.00%> (-0.18%) ⬇️
pkg/util/util.go 39.47% <28.57%> (ø)
pkg/devfile/parser/data/v2/containers.go 80.31% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Signed-off-by: Kim Tsao <ktsao@redhat.com>
Signed-off-by: Kim Tsao <ktsao@redhat.com>
Signed-off-by: Kim Tsao <ktsao@redhat.com>
Signed-off-by: Kim Tsao <ktsao@redhat.com>
Signed-off-by: Kim Tsao <ktsao@redhat.com>
@@ -38,7 +38,7 @@
fmt.Printf("Writing to file: %s\n", filePath)
fileContent := fmt.Sprintf("package %s\n\n// %s\nconst %s = `%s\n`\n", packageVersion, schemaURL, jsonSchemaVersion, newSchema)

if err := ioutil.WriteFile(filePath, []byte(fileContent), 0755); err != nil {
if err := ioutil.WriteFile(filePath, []byte(fileContent), 0644); err != nil {

Check failure

Code scanning / gosec

Expect WriteFile permissions to be 0600 or less

Expect WriteFile permissions to be 0600 or less
Copy link
Member

Choose a reason for hiding this comment

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

does this not fail the github CI @kim-tsao ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This only place this seems to get called is from main.go which is called from the updateAPI.sh script (run locally) to sync the api dependency

@kim-tsao
Copy link
Contributor Author

Handled all Gosec findings by either fixing them or annotating them with nosec. Some details of the fixes include:

  • Following the guideline for G304 to clean user provided filepaths in order to avoid path traversal
  • Updating the permissions to 0644 if the JSON schema is updated and replaced. This is not a security concern since it's part of a script that's run outside core code to update the API dependency so I restricted the level of permissions based on our current defaults. This will not eliminate the finding since it expects 0600 but I think 0644 is appropriate for our needs

@kim-tsao kim-tsao marked this pull request as ready for review September 23, 2022 20:01
@kim-tsao kim-tsao requested review from yangcao77, johnmcollier and maysunfaisal and removed request for elsony and maysunfaisal September 23, 2022 20:01
@openshift-ci
Copy link

openshift-ci bot commented Oct 3, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kim-tsao, maysunfaisal

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [kim-tsao,maysunfaisal]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kim-tsao kim-tsao merged commit 8b432ca into devfile:main Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants