Skip to content

Commit 4d9b203

Browse files
fix file format
1 parent 4db4cdd commit 4d9b203

4 files changed

Lines changed: 19 additions & 12 deletions

File tree

internal/commands/scan_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,6 @@ func TestAddAiscScan_WhenAiscEnabledAndFeatureFlagEnabled_ShouldReturnConfig(t *
859859
}
860860

861861
func TestAddAiscScan_WhenAiscDisabled_ShouldReturnNil(t *testing.T) {
862-
863862
wrappers.ClearCache()
864863
var resubmitConfig []wrappers.Config
865864
mock.Flag = wrappers.FeatureFlagResponseModel{
@@ -876,7 +875,6 @@ func TestAddAiscScan_WhenAiscDisabled_ShouldReturnNil(t *testing.T) {
876875
}
877876

878877
func TestAddAiscScan_WhenFeatureFlagDisabled_ShouldReturnNil(t *testing.T) {
879-
880878
wrappers.ClearCache()
881879
var resubmitConfig []wrappers.Config
882880
mock.Flag = wrappers.FeatureFlagResponseModel{

internal/wrappers/results.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ type ResultsWrapper interface {
77

88
// ScanSummariesModel model used to parse the response from the scan-summary API
99
type ScanSummariesModel struct {
10-
ScansSummaries []ScanSumaries `json:"scansSummaries,omitempty,"`
11-
TotalCount int `json:"totalCount,omitempty,"`
10+
ScansSummaries []ScanSumaries `json:"scansSummaries,omitempty"`
11+
TotalCount int `json:"totalCount,omitempty"`
1212
}
1313

1414
type ScanSumaries struct {
@@ -45,13 +45,13 @@ type ScaCounters struct {
4545

4646
// ScaPackagesCounters contains counters for SCA packages.
4747
type ScaPackagesCounters struct {
48-
SeverityCounters []SeverityCounters `json:"severityCounters,omitempty"`
49-
StatusCounters []StatusCounters `json:"statusCounters,omitempty"`
50-
StateCounters []StateCounters `json:"stateCounters,omitempty"`
51-
TotalCounter int `json:"totalCounter,omitempty"`
52-
OutdatedCounter int `json:"outdatedCounter,omitempty"`
48+
SeverityCounters []SeverityCounters `json:"severityCounters,omitempty"`
49+
StatusCounters []StatusCounters `json:"statusCounters,omitempty"`
50+
StateCounters []StateCounters `json:"stateCounters,omitempty"`
51+
TotalCounter int `json:"totalCounter,omitempty"`
52+
OutdatedCounter int `json:"outdatedCounter,omitempty"`
5353
RiskLevelCounters []RiskLevelCounters `json:"riskLevelCounters,omitempty"`
54-
LicenseCounters []LicenseCounters `json:"licenseCounters,omitempty"`
54+
LicenseCounters []LicenseCounters `json:"licenseCounters,omitempty"`
5555
}
5656

5757
type ScaContainersCounters struct {
@@ -146,4 +146,4 @@ type SeverityStatusCounters struct {
146146
Severity string `json:"severity,omitempty"`
147147
Status string `json:"status,omitempty"`
148148
Counter int `json:"counter,omitempty"`
149-
}
149+
}

internal/wrappers/scan-summary-http.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,14 @@ func NewHTTPScanSummaryWrapper(path string) ScanSummaryWrapper {
2525
path: path,
2626
}
2727
}
28+
2829
// GetScanSummaryByScanID retrieves the scan summary for a given scan ID by making an HTTP GET request to the configured path.
2930
func (s *ScanSummaryHTTPWrapper) GetScanSummaryByScanID(scanID string) (*ScanSummariesModel, *WebError, error) {
3031
clientTimeout := viper.GetUint(commonParams.ClientTimeoutKey)
32+
3133
// Construct the path with query parameter
3234
path := fmt.Sprintf("%s?scan-ids=%s", s.path, scanID)
35+
3336
resp, err := SendHTTPRequest(http.MethodGet, path, http.NoBody, true, clientTimeout)
3437
if err != nil {
3538
return nil, nil, err
@@ -39,7 +42,9 @@ func (s *ScanSummaryHTTPWrapper) GetScanSummaryByScanID(scanID string) (*ScanSum
3942
_ = resp.Body.Close()
4043
}
4144
}()
45+
4246
decoder := json.NewDecoder(resp.Body)
47+
4348
switch resp.StatusCode {
4449
case http.StatusBadRequest, http.StatusInternalServerError:
4550
errorModel := WebError{}
@@ -48,16 +53,19 @@ func (s *ScanSummaryHTTPWrapper) GetScanSummaryByScanID(scanID string) (*ScanSum
4853
return nil, nil, errors.Wrapf(err, failedToParseScanSummary)
4954
}
5055
return nil, &errorModel, nil
56+
5157
case http.StatusOK:
5258
model := ScanSummariesModel{}
5359
err = decoder.Decode(&model)
5460
if err != nil {
5561
return nil, nil, errors.Wrapf(err, failedToParseScanSummary)
5662
}
5763
return &model, nil, nil
64+
5865
case http.StatusNotFound:
5966
return nil, nil, errors.Errorf("scan summary not found for scan ID: %s", scanID)
67+
6068
default:
6169
return nil, nil, errors.Errorf("response status code %d", resp.StatusCode)
6270
}
63-
}
71+
}

internal/wrappers/scans.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,5 +164,6 @@ type SCSConfig struct {
164164
GitCommitHistory string `json:"gitCommitHistory,omitempty"`
165165
}
166166

167+
// AISCConfig is a placeholder for AISC scan configurations.
167168
type AISCConfig struct {
168169
}

0 commit comments

Comments
 (0)