(ctx context.Context, parent *model.File, files []*model.File, call model.ResCallback)
| 24 | } |
| 25 | |
| 26 | func (sca Sca) Sca(ctx context.Context, parent *model.File, files []*model.File, call model.ResCallback) { |
| 27 | |
| 28 | // jar包中的pom仅读取pom自身信息 不获取子依赖 |
| 29 | if strings.Contains(parent.Relpath(), ".jar") { |
| 30 | for _, file := range files { |
| 31 | if !filter.JavaPom(file.Relpath()) { |
| 32 | continue |
| 33 | } |
| 34 | file.OpenReader(func(reader io.Reader) { |
| 35 | p := ReadPom(reader) |
| 36 | p.Update(&p.PomDependency) |
| 37 | if !p.Check() { |
| 38 | return |
| 39 | } |
| 40 | call(file, &model.DepGraph{ |
| 41 | Vendor: p.GroupId, |
| 42 | Name: p.ArtifactId, |
| 43 | Version: p.Version, |
| 44 | Path: file.Relpath(), |
| 45 | }) |
| 46 | }) |
| 47 | } |
| 48 | return |
| 49 | } |
| 50 | |
| 51 | // 记录pom文件 |
| 52 | poms := []*Pom{} |
| 53 | for _, file := range files { |
| 54 | if filter.JavaPom(file.Relpath()) { |
| 55 | file.OpenReader(func(reader io.Reader) { |
| 56 | pom := ReadPom(reader) |
| 57 | pom.File = file |
| 58 | poms = append(poms, pom) |
| 59 | }) |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | // 记录不需要静态解析的pom |
| 64 | var exclusionPom []*Pom |
| 65 | |
| 66 | // 优先尝试调用mvn |
| 67 | if !sca.NotUseMvn { |
| 68 | for _, pom := range poms { |
| 69 | dep := MvnTree(ctx, pom) |
| 70 | if dep != nil { |
| 71 | call(pom.File, dep) |
| 72 | exclusionPom = append(exclusionPom, pom) |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | // 静态解析 |
| 78 | if !sca.NotUseStatic { |
| 79 | ParsePoms(ctx, poms, exclusionPom, func(pom *Pom, root *model.DepGraph) { |
| 80 | call(pom.File, root) |
| 81 | }) |
| 82 | } |
| 83 | } |
nothing calls this directly
no test coverage detected