diff --git a/output/output.go b/output/output.go index 74b1f89..060783a 100644 --- a/output/output.go +++ b/output/output.go @@ -6,7 +6,7 @@ import ( "os" "regexp" "runtime/debug" - "strings" + "time" "github.com/certinia/asist/config" @@ -64,17 +64,14 @@ func DisplayOutput(finalResult *finding.Output, scanTime *ScanTime) { } /** - * extractRepoNameFromURL - method used to extract repoFolder/repoName from a sshUrl of repository + * extractRepoNameFromURL - method used to extract repoName from a sshUrl of repository */ func extractRepoNameFromURL(url string) string { if url != "" { - findRepoNameRegexp := regexp.MustCompile(`(?i)[a-z0-9-_.]+/[a-z0-9-_.]+\.git$`) + findRepoNameRegexp := regexp.MustCompile(`(?i)/([a-z0-9-_.]+)\.git$`) match := findRepoNameRegexp.FindStringSubmatch(url) - if len(match) > 0 { - parts := strings.Split(match[0], ".git") - if len(parts) > 1 { - return parts[0] - } + if len(match) > 1 { + return match[1] } } return "" diff --git a/output/output_test.go b/output/output_test.go index b100854..d82a310 100644 --- a/output/output_test.go +++ b/output/output_test.go @@ -34,13 +34,13 @@ func TestCreateBaselineOutput(t *testing.T) { baselineOutputContent := finding.BaselineOutputContent{FindingID: "431d4935962ceb80271200", IsCustom: false, IsFalsePositive: false, Id: "ExposedMessageChannel", Severity: "High", RuleCategory: "Security"} expectedBaselineOutput := []finding.BaselineOutput{ { - RepositoryName: "test/test", + RepositoryName: "test", RepositoryURL: sshUrl, RecordType: "Finding", Content: baselineOutputContent, }, { - RepositoryName: "test/test", + RepositoryName: "test", RepositoryURL: sshUrl, RecordType: "Config", Content: config.GetConfigInstance(),