MCPcopy Create free account
hub / github.com/XmirrorSecurity/OpenSCA-cli / ParsePipfileLock

Function ParsePipfileLock

opensca/sca/python/pip.go:44–68  ·  view source on GitHub ↗
(file *model.File)

Source from the content-addressed store, hash-verified

42}
43
44func ParsePipfileLock(file *model.File) *model.DepGraph {
45
46 lock := struct {
47 Default map[string]struct {
48 Version string `json:"version"`
49 } `json:"default"`
50 }{}
51
52 root := &model.DepGraph{Path: file.Relpath()}
53
54 _dep := model.NewDepGraphMap(nil, func(s ...string) *model.DepGraph { return &model.DepGraph{Name: s[0], Version: s[1]} }).LoadOrStore
55
56 file.OpenReader(func(reader io.Reader) {
57 if err := json.NewDecoder(reader).Decode(&lock); err != nil {
58 logs.Warnf("unmarshal file %s err: %s", file.Relpath(), err)
59 }
60 })
61
62 for name, v := range lock.Default {
63 version := strings.TrimPrefix(v.Version, "==")
64 root.AppendChild(_dep(name, version))
65 }
66
67 return root
68}
69
70func ParseRequirementTxt(file *model.File) *model.DepGraph {
71

Callers 1

ScaMethod · 0.85

Calls 6

AppendChildMethod · 0.95
NewDepGraphMapFunction · 0.92
WarnfFunction · 0.92
RelpathMethod · 0.80
OpenReaderMethod · 0.80
DecodeMethod · 0.80

Tested by

no test coverage detected