FEAT: add health-score-threshold option to cicheck command for CI/CD … - #67
Conversation
utkarshpandey12
left a comment
There was a problem hiding this comment.
requested changes
| waitForStaticScan(fileID, staticScanTimeout) | ||
| ctx := context.Background() | ||
| client := getClient() | ||
| _, analysisResponse, err := client.Analyses.ListByFile(ctx, fileID, nil) |
There was a problem hiding this comment.
the error from the first Analyses.ListByFile call is never checked before calling analysisResponse.GetCount(). Add PrintError/exit path used elsewhere in the function in case of failure
| func (s *FilesService) GetHealthScore(ctx context.Context, fileID int, eventType string) (*HealthScore, *Response, error) { | ||
| u := fmt.Sprintf("api/v3/files/%v/health_score", fileID) | ||
| if eventType != "" { | ||
| u = fmt.Sprintf("%s?event_type=%s", u, eventType) |
There was a problem hiding this comment.
use existing addOptions helper to builds the event_type query param
| ctx := context.Background() | ||
| client := getClient() | ||
|
|
||
| healthScoreResponse, _, err := client.Files.GetHealthScore(ctx, fileID, "sast_completed") |
There was a problem hiding this comment.
consider defining and using event_type as a proper enum
| return buf.String(), err | ||
| } | ||
|
|
||
| func TestCiCheckCommand_BothThresholdsProvided(t *testing.T) { |
There was a problem hiding this comment.
This test just I guess never actually runs cicheckCmd. So if the real flag check in Run() breaks, this test would still pass.
| resetCiCheckFlags() | ||
| } | ||
|
|
||
| func TestCiCheckCommand_RiskThresholdValues(t *testing.T) { |
There was a problem hiding this comment.
validate via actual run cmd
| resetCiCheckFlags() | ||
| } | ||
|
|
||
| func TestCiCheckCommand_HealthScoreValidation(t *testing.T) { |
There was a problem hiding this comment.
validate via actual run cmd
|



Changelog
Add health score endpoint support in FilesService
Add health score threshold mode to cicheck command
--health-score-thresholdflag (0-100) as alternative to--risk-thresholdRefactor cicheck helper to support both modes
health_score >= threshold, fails otherwiseAdd comprehensive test coverage
Update documentation
Dependent PRs