fix: more python matching support (#1667)

This commit is contained in:
Keith Zantow
2023-03-13 13:26:43 -04:00
committed by GitHub
parent b379dd9f27
commit cc0a376aba
8 changed files with 231134 additions and 8 deletions
+6
View File
@@ -9,6 +9,7 @@ import (
"io"
"reflect"
"regexp"
"strings"
"text/template"
"github.com/anchore/packageurl-go"
@@ -79,6 +80,11 @@ func fileNameTemplateVersionMatcher(fileNamePattern string, contentTemplate stri
filepathNamedGroupValues := internal.MatchNamedCaptureGroups(pat, location.RealPath)
// versions like 3.5 should not match any character, but explicit dot
for k, v := range filepathNamedGroupValues {
filepathNamedGroupValues[k] = strings.ReplaceAll(v, ".", "\\.")
}
tmpl, err := template.New("").Parse(contentTemplate)
if err != nil {
return nil, fmt.Errorf("unable to parse classifier template=%q : %w", contentTemplate, err)