From 25623fb2de4173ddfafbee57a85949939c53dae8 Mon Sep 17 00:00:00 2001 From: zhangzhenyu <8419196+zhangzhenyu_1_0@user.noreply.gitee.com> Date: Tue, 19 Nov 2024 08:33:33 +0000 Subject: [PATCH] update pkg/inventory/pckg/collector/maven/gradle_file_parser.go. Avoid starting index greater than or equal to the slice length. Signed-off-by: zhangzhenyu <8419196+zhangzhenyu_1_0@user.noreply.gitee.com> --- pkg/inventory/pckg/collector/maven/gradle_file_parser.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/inventory/pckg/collector/maven/gradle_file_parser.go b/pkg/inventory/pckg/collector/maven/gradle_file_parser.go index d21e902..23ade53 100644 --- a/pkg/inventory/pckg/collector/maven/gradle_file_parser.go +++ b/pkg/inventory/pckg/collector/maven/gradle_file_parser.go @@ -129,6 +129,11 @@ func parseGradleFile(reader io.Reader, sourcePath string) ([]model.Package, erro }) + 1 end := len(line) - 1 + + // Avoid crossing the line + if start <= 0 || start >= end { + continue + } dependencyStr := trimCustomString(line[start:end], trimStringArr) dependencyParts := strings.Split(dependencyStr, ":") -- Gitee