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 SSCS as scan type for the triage command (AST-72075) #1022

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

cx-ruio
Copy link
Collaborator

@cx-ruio cx-ruio commented Jan 28, 2025

By submitting a PR to this repository, you agree to the terms within the Checkmarx Code of Conduct. Please see the contributing guidelines for how to create and submit a high-quality PR for this repo.

Description

SSCS triaging capabilities.

References

https://checkmarx.atlassian.net/browse/AST-72075

Testing

Checklist

  • I have added documentation for new/changed functionality in this PR (if applicable).
  • I have updated the CLI help for new/changed functionality in this PR (if applicable).
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used

Copy link

github-actions bot commented Jan 28, 2025

Logo
Checkmarx One – Scan Summary & Detailsbaa022b3-3850-456f-a6c4-102cbffe07f7

Great job, no security vulnerabilities found in this Pull Request

@cx-ruio cx-ruio force-pushed the feature/AST-72075-cli-add-sscs-as-scan-type-for-the-triage-command branch from 1a51196 to c22a73a Compare January 28, 2025 18:03
type ScanOverviewHTTPWrapper struct {
path string
}

func NewHTTPScanOverviewWrapper(path string) ScanOverviewWrapper {
validPath := configurePath(path)
Copy link

Choose a reason for hiding this comment

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

The configurePath function is not defined within the provided diff. Ensure that the function exists and is properly implemented to handle the path parameter. If it's defined in another file, make sure it is correctly imported and accessible in this context.

internal/wrappers/scan-overview-http.go Outdated Show resolved Hide resolved
internal/wrappers/scan-overview-http.go Show resolved Hide resolved
internal/wrappers/scan-overview-http.go Outdated Show resolved Hide resolved
internal/wrappers/scan-overview-http.go Show resolved Hide resolved
internal/wrappers/scan-overview-http.go Show resolved Hide resolved
internal/commands/util/configuration_test.go Show resolved Hide resolved
func TestWriteSingleConfigKeyStringNonExistingFile_CreatingTheFileAndWritesTheKey_Success(t *testing.T) {
configFilePath := "non-existing-file"

file, err := os.Open(configFilePath)
Copy link

Choose a reason for hiding this comment

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

The file handle file is not closed after opening. Consider deferring the close operation immediately after checking the error from os.Open to avoid resource leaks.

Copy link
Collaborator

@AlvoBen AlvoBen Feb 6, 2025

Choose a reason for hiding this comment

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

Close th file

internal/commands/util/configuration_test.go Show resolved Hide resolved
internal/commands/util/configuration_test.go Show resolved Hide resolved
@cx-ruio cx-ruio force-pushed the feature/AST-72075-cli-add-sscs-as-scan-type-for-the-triage-command branch from 86b550a to 2375f6f Compare February 6, 2025 11:53
internal/commands/predicates.go Show resolved Hide resolved
internal/commands/util/configuration_test.go Show resolved Hide resolved
internal/commands/util/configuration_test.go Show resolved Hide resolved

file, err = os.Open(configFilePath)
assert.NilError(t, err)
defer func(file *os.File) {
Copy link

Choose a reason for hiding this comment

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

Use file.Close() and os.Remove(configFilePath) directly without the anonymous function wrapper since there's no additional logic that requires the use of defer in this context.

internal/commands/util/configuration_test.go Show resolved Hide resolved
internal/wrappers/scan-overview-http.go Show resolved Hide resolved
internal/wrappers/scan-overview-http.go Show resolved Hide resolved
internal/wrappers/scan-overview-http.go Show resolved Hide resolved
internal/wrappers/scan-overview-http.go Show resolved Hide resolved
internal/wrappers/scan-overview-http.go Show resolved Hide resolved
func TestWriteSingleConfigKeyStringNonExistingFile_CreatingTheFileAndWritesTheKey_Success(t *testing.T) {
configFilePath := "non-existing-file"

file, err := os.Open(configFilePath)
Copy link
Collaborator

@AlvoBen AlvoBen Feb 6, 2025

Choose a reason for hiding this comment

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

Close th file

internal/wrappers/scan-overview-http.go Show resolved Hide resolved
file, err := os.Open(configFilePath)
asserts.NotNil(t, err)
asserts.Nil(t, file)
err = file.Close()

Choose a reason for hiding this comment

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

Attempting to close a file that failed to open is unnecessary and could lead to a nil pointer dereference. Remove the file.Close() call and the subsequent error check.

AlvoBen
AlvoBen previously approved these changes Feb 11, 2025
@cx-ruio cx-ruio force-pushed the feature/AST-72075-cli-add-sscs-as-scan-type-for-the-triage-command branch from ed90b74 to 2375f6f Compare February 11, 2025 12:22
@cx-ruio cx-ruio force-pushed the feature/AST-72075-cli-add-sscs-as-scan-type-for-the-triage-command branch from 2375f6f to 0ade878 Compare February 11, 2025 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants