Fix RelSource for Files

This commit is contained in:
suhasgumma
2022-11-29 23:55:19 +05:30
committed by Vlad Klokun
parent a3defe3025
commit 92a2704fa6
2 changed files with 15 additions and 3 deletions

View File

@@ -62,11 +62,12 @@ func NewFixHandler(fixInfo *metav1.FixInfo) (*FixHandler, error) {
}
func isSupportedScanningTarget(report *reporthandlingv2.PostureReport) error {
if report.Metadata.ScanMetadata.ScanningTarget == reporthandlingv2.GitLocal || report.Metadata.ScanMetadata.ScanningTarget == reporthandlingv2.Directory {
scanningTarget := report.Metadata.ScanMetadata.ScanningTarget
if scanningTarget == reporthandlingv2.GitLocal || scanningTarget == reporthandlingv2.Directory || scanningTarget == reporthandlingv2.File {
return nil
}
return fmt.Errorf("unsupported scanning target. Only local git and directory scanning targets are supported")
return fmt.Errorf("unsupported scanning target. Only local git, directory and file scanning targets are supported")
}
func getLocalPath(report *reporthandlingv2.PostureReport) string {
@@ -78,6 +79,10 @@ func getLocalPath(report *reporthandlingv2.PostureReport) string {
return report.Metadata.ContextMetadata.DirectoryContextMetadata.BasePath
}
if report.Metadata.ScanMetadata.ScanningTarget == reporthandlingv2.File {
return report.Metadata.ContextMetadata.FileContextMetadata.FilePath
}
return ""
}