-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for incremental scan appearing as Full scan when using scan list …
…command (#623) * fixing for incremental scan appearing as Full scan when using scan list command
- Loading branch information
1 parent
8f085fa
commit 1e84dc6
Showing
16 changed files
with
228 additions
and
29 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package mock | ||
|
||
import "github.com/checkmarx/ast-cli/internal/wrappers" | ||
|
||
type SastMetadataMockWrapper struct{} | ||
|
||
func (s SastMetadataMockWrapper) GetSastMetadataByIDs(params map[string]string) ( | ||
*wrappers.SastMetadataModel, | ||
error, | ||
) { | ||
return &wrappers.SastMetadataModel{ | ||
TotalCount: 2, | ||
Scans: []wrappers.Scans{ | ||
{ | ||
ScanID: "scan1", | ||
ProjectID: "project1", | ||
Loc: 100, | ||
FileCount: 50, | ||
IsIncremental: true, | ||
AddedFilesCount: 10, | ||
ChangedFilesCount: 5, | ||
}, | ||
{ | ||
ScanID: "scan2", | ||
ProjectID: "project2", | ||
Loc: 150, | ||
FileCount: 70, | ||
IsIncremental: false, | ||
IsIncrementalCanceled: true, | ||
IncrementalCancelReason: "Some reason", | ||
BaseID: "baseID", | ||
DeletedFilesCount: 3, | ||
}, | ||
}, | ||
Missing: []string{"missing1", "missing2"}, | ||
}, nil | ||
} |
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 |
---|---|---|
|
@@ -2,7 +2,6 @@ package mock | |
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/checkmarx/ast-cli/internal/wrappers" | ||
) | ||
|
||
|
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,55 @@ | ||
package wrappers | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"net/http" | ||
|
||
commonParams "github.com/checkmarx/ast-cli/internal/params" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
type SastIncrementalHTTPWrapper struct { | ||
path string | ||
contentType string | ||
} | ||
|
||
func NewSastIncrementalHTTPWrapper(path string) SastMetadataWrapper { | ||
return &SastIncrementalHTTPWrapper{ | ||
path: path, | ||
contentType: "application/json", | ||
} | ||
} | ||
|
||
func (s *SastIncrementalHTTPWrapper) GetSastMetadataByIDs(params map[string]string) (*SastMetadataModel, error) { | ||
clientTimeout := viper.GetUint(commonParams.ClientTimeoutKey) | ||
|
||
resp, err := SendPrivateHTTPRequestWithQueryParams(http.MethodGet, s.path, params, http.NoBody, clientTimeout) | ||
if err != nil { | ||
return nil, err | ||
} | ||
decoder := json.NewDecoder(resp.Body) | ||
|
||
defer resp.Body.Close() | ||
|
||
switch resp.StatusCode { | ||
case http.StatusBadRequest, http.StatusInternalServerError: | ||
errorModel := ErrorModel{} | ||
err = decoder.Decode(&errorModel) | ||
if err != nil { | ||
return nil, fmt.Errorf("%v %s", err, failedToParseGetAll) | ||
} | ||
return nil, err | ||
case http.StatusOK: | ||
model := SastMetadataModel{} | ||
err = decoder.Decode(&model) | ||
if err != nil { | ||
return nil, fmt.Errorf("%v %s", err, failedToParseGetAll) | ||
} | ||
return &model, nil | ||
case http.StatusNotFound: | ||
return nil, fmt.Errorf("scan not found") | ||
default: | ||
return nil, fmt.Errorf("response status code %d", resp.StatusCode) | ||
} | ||
} |
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,25 @@ | ||
package wrappers | ||
|
||
type SastMetadataWrapper interface { | ||
GetSastMetadataByIDs(params map[string]string) (*SastMetadataModel, error) | ||
} | ||
|
||
type SastMetadataModel struct { | ||
TotalCount int `json:"totalCount"` | ||
Scans []Scans `json:"scans"` | ||
Missing []string `json:"missing"` | ||
} | ||
type Scans struct { | ||
ScanID string `json:"scanId,omitempty"` | ||
ProjectID string `json:"projectId,omitempty"` | ||
Loc int `json:"loc,omitempty"` | ||
FileCount int `json:"fileCount,omitempty"` | ||
IsIncremental bool `json:"isIncremental,omitempty"` | ||
IsIncrementalCanceled bool `json:"isIncrementalCanceled,omitempty"` | ||
IncrementalCancelReason string `json:"incrementalCancelReason,omitempty"` | ||
BaseID string `json:"baseId,omitempty"` | ||
AddedFilesCount int `json:"addedFilesCount,omitempty"` | ||
ChangedFilesCount int `json:"changedFilesCount,omitempty"` | ||
DeletedFilesCount int `json:"deletedFilesCount,omitempty"` | ||
QueryPreset string `json:"queryPreset,omitempty"` | ||
} |
Oops, something went wrong.