From f1128b29a5799a7bb68d83488b0aa996a5fa3e67 Mon Sep 17 00:00:00 2001 From: Emily McMullan Date: Mon, 25 Nov 2024 11:43:03 -0500 Subject: [PATCH] analyze known libs for containerless Signed-off-by: Emily McMullan --- .github/workflows/release-artifacts.yaml | 3 +++ cmd/analyze-bin.go | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/.github/workflows/release-artifacts.yaml b/.github/workflows/release-artifacts.yaml index a00a134..350a82e 100644 --- a/.github/workflows/release-artifacts.yaml +++ b/.github/workflows/release-artifacts.yaml @@ -49,16 +49,19 @@ jobs: podman cp kantra-download:/bin/fernflower.jar . && zip kantra.linux.${{ matrix.arch }}.zip fernflower.jar podman cp kantra-download:/usr/local/static-report . && zip -r kantra.linux.${{ matrix.arch }}.zip static-report podman cp kantra-download:/opt/rulesets . && zip -r kantra.linux.${{ matrix.arch }}.zip rulesets + podman cp kantra-download:/usr/local/etc/maven.default.index . && zip -r kantra.linux.${{ matrix.arch }}.zip maven.default.index podman cp kantra-download:/jdtls . && zip -r kantra.darwin.${{ matrix.arch }}.zip jdtls podman cp kantra-download:/bin/fernflower.jar . && zip kantra.darwin.${{ matrix.arch }}.zip fernflower.jar podman cp kantra-download:/usr/local/static-report . && zip -r kantra.darwin.${{ matrix.arch }}.zip static-report podman cp kantra-download:/opt/rulesets . && zip -r kantra.darwin.${{ matrix.arch }}.zip rulesets + podman cp kantra-download:/usr/local/etc/maven.default.index . && zip -r kantra.darwin.${{ matrix.arch }}.zip maven.default.index podman cp kantra-download:/jdtls . && zip -r kantra.windows.${{ matrix.arch }}.zip jdtls podman cp kantra-download:/bin/fernflower.jar . && zip kantra.windows.${{ matrix.arch }}.zip fernflower.jar podman cp kantra-download:/usr/local/static-report . && zip -r kantra.windows.${{ matrix.arch }}.zip static-report podman cp kantra-download:/opt/rulesets . && zip -r kantra.windows.${{ matrix.arch }}.zip rulesets + podman cp kantra-download:/usr/local/etc/maven.default.index . && zip -r kantra.windows.${{ matrix.arch }}.zip maven.default.index - name: Upload linux binary uses: actions/upload-release-asset@v1 diff --git a/cmd/analyze-bin.go b/cmd/analyze-bin.go index f549036..b536b3c 100644 --- a/cmd/analyze-bin.go +++ b/cmd/analyze-bin.go @@ -99,6 +99,16 @@ func (a *analyzeCommand) RunAnalysisContainerless(ctx context.Context) error { selectors = append(selectors, selector) } + var dependencyLabelSelector *labels.LabelSelector[*konveyor.Dep] + depLabel := fmt.Sprintf("%v=open-source", provider.DepSourceLabel) + if a.analyzeKnownLibraries { + dependencyLabelSelector, err = labels.NewLabelSelector[*konveyor.Dep](depLabel, nil) + if err != nil { + errLog.Error(err, "failed to create label selector from expression", "selector", depLabel) + os.Exit(1) + } + } + err = a.setBinMapContainerless() if err != nil { a.log.Error(err, "unable to find kantra dependencies") @@ -128,6 +138,7 @@ func (a *analyzeCommand) RunAnalysisContainerless(ctx context.Context) error { parser := parser.RuleParser{ ProviderNameToClient: providers, Log: analyzeLog.WithName("parser"), + DepLabelSelector: dependencyLabelSelector, } ruleSets := []engine.RuleSet{} @@ -368,6 +379,7 @@ func (a *analyzeCommand) createProviderConfigsContainerless() ([]provider.Config "lspServerName": javaProvider, "bundles": a.reqMap["bundle"], provider.LspServerPathConfigKey: a.reqMap["jdtls"], + "depOpenSourceLabelsFile": filepath.Join(a.kantraDir, "maven.default.index"), }, }, },