Skip to content

Commit a3fc297

Browse files
committed
feat(poerty): add parse tool.poetry.group.<group_name>.dependencies
1 parent 7e427bb commit a3fc297

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

module/poetry/poetry.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ package poetry
33
import (
44
"context"
55
"fmt"
6+
"path/filepath"
7+
"regexp"
8+
"strings"
9+
610
"github.com/murphysecurity/murphysec/model"
711
"github.com/murphysecurity/murphysec/utils"
812
"github.com/pelletier/go-toml/v2"
913
"github.com/pkg/errors"
10-
"path/filepath"
11-
"regexp"
12-
"strings"
1314
)
1415

1516
var ErrParsePoetry = poetryErr("ErrParsePoetry: Bad manifest")
@@ -95,6 +96,21 @@ func parsePoetry(input []byte) (*Manifest, error) {
9596
m[k] = v
9697
}
9798
}
99+
100+
// 解析 [tool.poetry.group.<group_name>.dependencies]
101+
if groups, ok := root.Get("tool", "poetry", "group").v.(map[string]any); ok {
102+
for _, group := range groups {
103+
if groupMap, ok := group.(map[string]any); ok {
104+
if deps, ok := groupMap["dependencies"].(map[string]any); ok {
105+
for k, v := range deps {
106+
m[k] = v
107+
}
108+
}
109+
}
110+
}
111+
}
112+
113+
// 解析 [project.dependencies](兼容性处理)
98114
if mm, ok := root.Get("project", "dependencies").v.([]any); ok {
99115
for _, _s := range mm {
100116
var s, ok = _s.(string)

0 commit comments

Comments
 (0)