From daca0800d4d078a568d001e42c018fecc141ad96 Mon Sep 17 00:00:00 2001 From: Pranav Gaikwad Date: Wed, 23 Aug 2023 10:42:19 -0400 Subject: [PATCH] :ghost: update doc, demo output Signed-off-by: Pranav Gaikwad --- Dockerfile | 2 +- README.md | 28 +++--- cmd/analyzer/main.go | 2 +- cmd/dep/main.go | 35 +++++--- demo-dep-output.yaml | 150 +++++++++++++++---------------- demo.Dockerfile | 3 +- docs/labels.md | 29 ++++++ docs/providers.md | 12 ++- provider_container_settings.json | 1 + 9 files changed, 157 insertions(+), 105 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4bf82554..9ebf7dc5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,4 +34,4 @@ WORKDIR /analyzer-lsp EXPOSE 16686 -ENTRYPOINT ["sh", "-c", "all-in-one-linux & sleep 5 && konveyor-analyzer"] +ENTRYPOINT ["sh", "-c", "all-in-one-linux &> /dev/null & sleep 5 && konveyor-analyzer"] diff --git a/README.md b/README.md index 8dabc3f4..daf14e98 100644 --- a/README.md +++ b/README.md @@ -39,18 +39,22 @@ go run cmd/analyzer/main.go CLI Options: ```sh - --analysis-mode string Can be full or source-only to tell the providers what to analyze. If full, source code and all dependencies will be analyzed, if source-only, only the source code will be. This can be given on a per provider basis, but this flag will override those. - --provider-settings string path to the provider settings (default "provider_settings.json") - --rules stringArray filename or directory containing rule files (default [rule-example.yaml]) - --output-file string filepath to to store rule violations (default "output.yaml") - --label-selector string an expression to select rules based on labels - --enable-jaeger enable tracer exports to jaeger endpoint - --error-on-violation exit with 3 if any violation are found will also print violations to console - --jaeger-endpoint string jaeger endpoint to collect tracing data (default "http://localhost:14268/api/traces") - --no-dependency-rules Disable dependency analysis rules - --limit-incidents int Set this to the limit incidents that a given rule can give. zero means no limit (default 1500) - --limit-code-snips int limit the number code snippets that are retrieved for a file while evaluating a rule, 0 means no limit (default 20) - --verbose int level for logging output (default 9) +Flags: + --analysis-mode string select one of full or source-only to tell the providers what to analyize. This can be given on a per provider setting, but this flag will override + --context-lines int When violation occurs, A part of source code is added to the output, So this flag configures the number of source code lines to be printed to the output. (default 10) + --dep-label-selector string an expression to select dependencies based on labels. This will filter out the violations from these dependencies as well these dependencies when matching dependency conditions + --enable-jaeger enable tracer exports to jaeger endpoint (default true) + --error-on-violation exit with 3 if any violation are found will also print violations to console + -h, --help help for analyze + --jaeger-endpoint string jaeger endpoint to collect tracing data (default "http://localhost:14268/api/traces") + --label-selector string an expression to select rules based on labels + --limit-code-snips int limit the number code snippets that are retrieved for a file while evaluating a rule, 0 means no limit (default 20) + --limit-incidents int Set this to the limit incidents that a given rule can give, zero means no limit (default 1500) + --no-dependency-rules Disable dependency analysis rules + --output-file string filepath to to store rule violations (default "output.yaml") + --provider-settings string path to the provider settings (default "provider_settings.json") + --rules stringArray filename or directory containing rule files (default [rule-example.yaml]) + --verbose int level for logging output (default 9) ``` * See [label selector](./docs/labels.md#label-selector) for more info on `--label-selector` option. diff --git a/cmd/analyzer/main.go b/cmd/analyzer/main.go index 97b4e87a..945fd333 100644 --- a/cmd/analyzer/main.go +++ b/cmd/analyzer/main.go @@ -55,7 +55,7 @@ func init() { rootCmd.Flags().StringVar(&labelSelector, "label-selector", "", "an expression to select rules based on labels") rootCmd.Flags().StringVar(&depLabelSelector, "dep-label-selector", "", "an expression to select dependencies based on labels. This will filter out the violations from these dependencies as well these dependencies when matching dependency conditions") rootCmd.Flags().IntVar(&logLevel, "verbose", 9, "level for logging output") - rootCmd.Flags().BoolVar(&enableJaeger, "enable-jaeger", true, "enable tracer exports to jaeger endpoint") + rootCmd.Flags().BoolVar(&enableJaeger, "enable-jaeger", false, "enable tracer exports to jaeger endpoint") rootCmd.Flags().StringVar(&jaegerEndpoint, "jaeger-endpoint", "http://localhost:14268/api/traces", "jaeger endpoint to collect tracing data") rootCmd.Flags().IntVar(&limitIncidents, "limit-incidents", 1500, "Set this to the limit incidents that a given rule can give, zero means no limit") rootCmd.Flags().IntVar(&limitCodeSnips, "limit-code-snips", 20, "limit the number code snippets that are retrieved for a file while evaluating a rule, 0 means no limit") diff --git a/cmd/dep/main.go b/cmd/dep/main.go index c49fb01b..42afa665 100644 --- a/cmd/dep/main.go +++ b/cmd/dep/main.go @@ -52,6 +52,15 @@ func main() { os.Exit(1) } + var labelSelector *labels.LabelSelector[*konveyor.Dep] + if depLabelSelector != "" { + labelSelector, err = labels.NewLabelSelector[*konveyor.Dep](depLabelSelector) + if err != nil { + log.Error(err, "invalid label selector") + os.Exit(1) + } + } + ctx, cancelFunc := context.WithCancel(context.Background()) defer cancelFunc() @@ -87,6 +96,7 @@ func main() { var depsFlat []konveyor.DepsFlatItem var depsTree []konveyor.DepsTreeItem + var provErr error for name, prov := range providers { if !provider.HasCapability(prov.Capabilities(), "dependency") { log.Info("provider does not have dependency capability", "provider", name) @@ -97,6 +107,7 @@ func main() { deps, err := prov.GetDependenciesDAG() if err != nil { log.Error(err, "failed to get list of dependencies for provider", "provider", name) + provErr = fmt.Errorf("%w", provErr) continue } for u, ds := range deps { @@ -110,18 +121,17 @@ func main() { deps, err := prov.GetDependencies() if err != nil { log.Error(err, "failed to get list of dependencies for provider", "provider", name) + provErr = fmt.Errorf("%w", provErr) continue } for u, ds := range deps { newDeps := ds - if depLabelSelector != "" { - l, err := labels.NewLabelSelector[*konveyor.Dep](depLabelSelector) + if labelSelector != nil { + newDeps, err = labelSelector.MatchList(ds) if err != nil { - panic(err) - } - newDeps, err = l.MatchList(ds) - if err != nil { - panic(err) + log.Error(err, "error matching label selector on deps") + provErr = fmt.Errorf("%w", provErr) + continue } } depsFlat = append(depsFlat, konveyor.DepsFlatItem{ @@ -133,8 +143,13 @@ func main() { } } - if depsFlat == nil && depsTree == nil { - log.Info("failed to get dependencies from all given providers") + // stop providers before exiting + for _, prov := range providers { + prov.Stop() + } + + if provErr != nil { + log.Error(provErr, "failed running dependency analysis") os.Exit(1) } @@ -162,8 +177,6 @@ func main() { } } - fmt.Printf("%s", string(b)) - err = os.WriteFile(outputFile, b, 0644) if err != nil { log.Error(err, "failed to write dependencies to output file", "file", outputFile) diff --git a/demo-dep-output.yaml b/demo-dep-output.yaml index 64b83b00..74d432fd 100644 --- a/demo-dep-output.yaml +++ b/demo-dep-output.yaml @@ -342,7 +342,7 @@ type: compile resolvedIdentifier: 9cb217a3d5b640567ed7c6e8c11f389613c81c4d labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/postgresql/postgresql/42.2.23 - name: org.checkerframework.checker-qual @@ -351,7 +351,7 @@ indirect: true resolvedIdentifier: 2f50520c8abea66fbd8d26e481d3aef5c673b510 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/checkerframework/checker-qual/3.5.0 - name: com.oracle.database.jdbc.ojdbc8 @@ -359,7 +359,7 @@ type: compile resolvedIdentifier: 50044485aea10afd7defeee8109c5195b4d3cae2 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/com/oracle/database/jdbc/ojdbc8/21.1.0.0 - name: ch.qos.logback.logback-classic @@ -367,7 +367,7 @@ type: compile resolvedIdentifier: 9865cf6994f9ff13fce0bf93f2054ef6c65bb462 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/ch/qos/logback/logback-classic/1.1.7 - name: ch.qos.logback.logback-core @@ -376,7 +376,7 @@ indirect: true resolvedIdentifier: 7873092d39ef741575ca91378a6a21c388363ac8 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/ch/qos/logback/logback-core/1.1.7 - name: org.hibernate.validator.hibernate-validator @@ -384,7 +384,7 @@ type: compile resolvedIdentifier: d6b0760dfffbf379cedd02f715ff4c9a2e215921 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/hibernate/validator/hibernate-validator/6.2.0.Final - name: jakarta.validation.jakarta.validation-api @@ -393,7 +393,7 @@ indirect: true resolvedIdentifier: 5eacc6522521f7eacb081f95cee1e231648461e7 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/jakarta/validation/jakarta.validation-api/2.0.2 - name: com.fasterxml.classmate @@ -402,7 +402,7 @@ indirect: true resolvedIdentifier: 3fe0bed568c62df5e89f4f174c101eab25345b6c labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/com/fasterxml/classmate/1.5.1 - name: org.hibernate.hibernate-entitymanager @@ -410,7 +410,7 @@ type: compile resolvedIdentifier: 3f60db4097732960ec792c033dbb7c34f1b9e328 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/hibernate/hibernate-entitymanager/5.4.32.Final - name: org.jboss.logging.jboss-logging @@ -419,7 +419,7 @@ indirect: true resolvedIdentifier: 40fd4d696c55793e996d1ff3c475833f836c2498 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/jboss/logging/jboss-logging/3.4.1.Final - name: org.hibernate.hibernate-core @@ -428,7 +428,7 @@ indirect: true resolvedIdentifier: 99a5e10bf455337014c190e141ec631e9ff71663 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/hibernate/hibernate-core/5.4.32.Final - name: org.javassist.javassist @@ -437,7 +437,7 @@ indirect: true resolvedIdentifier: f63e6aa899e15eca8fdaa402a79af4c417252213 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/javassist/javassist/3.27.0-GA - name: antlr.antlr @@ -447,7 +447,7 @@ resolvedIdentifier: | 83cd2cd674a217ade95a4bb83a8a14f351f48bd0 /home/maven/repository-staging/to-ibiblio/maven2/antlr/antlr/2.7.7/antlr-2.7.7.jar labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/antlr/antlr/2.7.7 - name: org.jboss.jandex @@ -456,7 +456,7 @@ indirect: true resolvedIdentifier: d3865101f0666b63586683bd811d754517f331ab labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/jboss/jandex/2.2.3.Final - name: javax.activation.javax.activation-api @@ -465,7 +465,7 @@ indirect: true resolvedIdentifier: 85262acf3ca9816f9537ca47d5adeabaead7cb16 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/javax/activation/javax.activation-api/1.2.0 - name: javax.xml.bind.jaxb-api @@ -474,7 +474,7 @@ indirect: true resolvedIdentifier: 8531ad5ac454cc2deb9d4d32c40c4d7451939b5d labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/javax/xml/bind/jaxb-api/2.3.1 - name: org.glassfish.jaxb.jaxb-runtime @@ -483,7 +483,7 @@ indirect: true resolvedIdentifier: dd6dda9da676a54c5b36ca2806ff95ee017d8738 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.1 - name: org.glassfish.jaxb.txw2 @@ -492,7 +492,7 @@ indirect: true resolvedIdentifier: a09d2c48d3285f206fafbffe0e50619284e92126 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/glassfish/jaxb/txw2/2.3.1 - name: com.sun.istack.istack-commons-runtime @@ -501,7 +501,7 @@ indirect: true resolvedIdentifier: c197c86ceec7318b1284bffb49b54226ca774003 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/com/sun/istack/istack-commons-runtime/3.0.7 - name: org.jvnet.staxex.stax-ex @@ -510,7 +510,7 @@ indirect: true resolvedIdentifier: 8cc35f73da321c29973191f2cf143d29d26a1df7 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/jvnet/staxex/stax-ex/1.8 - name: com.sun.xml.fastinfoset.FastInfoset @@ -519,7 +519,7 @@ indirect: true resolvedIdentifier: bb7b7ec0379982b97c62cd17465cb6d9155f68e8 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/com/sun/xml/fastinfoset/FastInfoset/1.2.15 - name: org.dom4j.dom4j @@ -528,7 +528,7 @@ indirect: true resolvedIdentifier: a75914155a9f5808963170ec20653668a2ffd2fd labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/dom4j/dom4j/2.1.3 - name: org.hibernate.common.hibernate-commons-annotations @@ -537,7 +537,7 @@ indirect: true resolvedIdentifier: e59ffdbc6ad09eeb33507b39ffcf287679a498c8 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/hibernate/common/hibernate-commons-annotations/5.1.2.Final - name: javax.persistence.javax.persistence-api @@ -546,7 +546,7 @@ indirect: true resolvedIdentifier: 25665ac8c0b62f50e6488173233239120fc52c96 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/javax/persistence/javax.persistence-api/2.2 - name: net.bytebuddy.byte-buddy @@ -555,7 +555,7 @@ indirect: true resolvedIdentifier: ef45d7e2cd1c600d279704f492ed5ce2ceb6cdb5 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/net/bytebuddy/byte-buddy/1.10.22 - name: org.jboss.spec.javax.transaction.jboss-transaction-api_1.2_spec @@ -564,7 +564,7 @@ indirect: true resolvedIdentifier: a8485cab9484dda36e9a8c319e76b5cc18797b58 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/jboss/spec/javax/transaction/jboss-transaction-api_1.2_spec/1.1.1.Final - name: org.apache.tomcat.tomcat-jdbc @@ -572,7 +572,7 @@ type: runtime resolvedIdentifier: 385cb6cb1f6b26c881cd5c1c6ade5f180712ffdc labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/apache/tomcat/tomcat-jdbc/9.0.46 - name: org.apache.tomcat.tomcat-juli @@ -581,7 +581,7 @@ indirect: true resolvedIdentifier: 409b519751e104eab51b4347a0d27bf86a4f3bb1 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/apache/tomcat/tomcat-juli/9.0.46 - name: org.springframework.boot.spring-boot-starter-actuator @@ -589,7 +589,7 @@ type: compile resolvedIdentifier: 8fc47befa38bdaa2f2b8f421d8532f03005e2851 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/springframework/boot/spring-boot-starter-actuator/2.5.0 - name: org.springframework.boot.spring-boot-starter @@ -598,7 +598,7 @@ indirect: true resolvedIdentifier: a910887c01efcc7d12f3f89a7604d436f26eeb90 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/springframework/boot/spring-boot-starter/2.5.0 - name: org.springframework.boot.spring-boot @@ -607,7 +607,7 @@ indirect: true resolvedIdentifier: b07513e04ad906ea69ef84293a123cdb83828f06 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/springframework/boot/spring-boot/2.5.0 - name: org.springframework.boot.spring-boot-autoconfigure @@ -616,7 +616,7 @@ indirect: true resolvedIdentifier: 64c7bbc941c70895621ed613f38dc66b73ea9341 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.5.0 - name: org.springframework.boot.spring-boot-starter-logging @@ -625,7 +625,7 @@ indirect: true resolvedIdentifier: 22401482ba1c5a1dcd3d33e47295779211b913d8 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.5.0 - name: org.apache.logging.log4j.log4j-to-slf4j @@ -634,7 +634,7 @@ indirect: true resolvedIdentifier: ce8a86a3f50a4304749828ce68e7478cafbc8039 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.14.1 - name: org.apache.logging.log4j.log4j-api @@ -643,7 +643,7 @@ indirect: true resolvedIdentifier: cd8858fbbde69f46bce8db1152c18a43328aae78 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/apache/logging/log4j/log4j-api/2.14.1 - name: org.slf4j.jul-to-slf4j @@ -652,7 +652,7 @@ indirect: true resolvedIdentifier: d58bebff8cbf70ff52b59208586095f467656c30 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/slf4j/jul-to-slf4j/1.7.30 - name: jakarta.annotation.jakarta.annotation-api @@ -661,7 +661,7 @@ indirect: true resolvedIdentifier: 59eb84ee0d616332ff44aba065f3888cf002cd2d labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/jakarta/annotation/jakarta.annotation-api/1.3.5 - name: org.yaml.snakeyaml @@ -670,7 +670,7 @@ indirect: true resolvedIdentifier: 7cae037c3014350c923776548e71c9feb7a69259 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/yaml/snakeyaml/1.28 - name: org.springframework.boot.spring-boot-actuator-autoconfigure @@ -679,7 +679,7 @@ indirect: true resolvedIdentifier: 41956882243e86f8260f649ebdd96597a2ff52a9 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/springframework/boot/spring-boot-actuator-autoconfigure/2.5.0 - name: org.springframework.boot.spring-boot-actuator @@ -688,7 +688,7 @@ indirect: true resolvedIdentifier: e0ac75f1a183f8e6a319a8b03bad1c45d40a2761 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/springframework/boot/spring-boot-actuator/2.5.0 - name: com.fasterxml.jackson.datatype.jackson-datatype-jsr310 @@ -697,7 +697,7 @@ indirect: true resolvedIdentifier: f69c636438dcf19c49960c1fe8901320ab85f989 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.12.3 - name: io.micrometer.micrometer-core @@ -706,7 +706,7 @@ indirect: true resolvedIdentifier: bc7dc1605f2099dc3c39156b7f62ac889f54fb67 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/io/micrometer/micrometer-core/1.7.0 - name: org.hdrhistogram.HdrHistogram @@ -715,7 +715,7 @@ indirect: true resolvedIdentifier: 6eb7552156e0d517ae80cc2247be1427c8d90452 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/hdrhistogram/HdrHistogram/2.1.12 - name: org.latencyutils.LatencyUtils @@ -724,7 +724,7 @@ indirect: true resolvedIdentifier: 769c0b82cb2421c8256300e907298a9410a2a3d3 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/latencyutils/LatencyUtils/2.0.3 - name: org.springframework.spring-web @@ -732,7 +732,7 @@ type: compile resolvedIdentifier: 49e6a8f45e77f14ef16f82c0413254ef493b785f labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/springframework/spring-web/5.3.7 - name: org.springframework.spring-webmvc @@ -740,7 +740,7 @@ type: compile resolvedIdentifier: 8437c7a572177a34607abdaef2f6b8088488f5c0 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/springframework/spring-webmvc/5.3.7 - name: org.springframework.spring-expression @@ -749,7 +749,7 @@ indirect: true resolvedIdentifier: 13351fce0a604957cd6a41478ebb54a953a0245e labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/springframework/spring-expression/5.3.7 - name: org.springframework.spring-jdbc @@ -757,7 +757,7 @@ type: compile resolvedIdentifier: 5caf72035a9b8a3a09ef82322cd2497aedddc487 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/springframework/spring-jdbc/5.3.7 - name: org.springframework.data.spring-data-jpa @@ -765,7 +765,7 @@ type: compile resolvedIdentifier: 881f7ae140f424b3bdb1b0c27a61b93e0bee9fa5 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/springframework/data/spring-data-jpa/2.5.1 - name: org.springframework.data.spring-data-commons @@ -774,7 +774,7 @@ indirect: true resolvedIdentifier: c950ca1a05e928e9fb75420b4ac07713428e9969 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/springframework/data/spring-data-commons/2.5.1 - name: org.springframework.spring-orm @@ -783,7 +783,7 @@ indirect: true resolvedIdentifier: f1892fe7a6671348d6546facbd40159b7e6f64a2 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/springframework/spring-orm/5.3.7 - name: org.springframework.spring-context @@ -792,7 +792,7 @@ indirect: true resolvedIdentifier: 330b3957efdcdebe3550b8e2c5d45a4c25496626 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/springframework/spring-context/5.3.7 - name: org.springframework.spring-aop @@ -801,7 +801,7 @@ indirect: true resolvedIdentifier: b86edd2455f8c4399068c999beb9ea2a9e7f2047 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/springframework/spring-aop/5.3.7 - name: org.springframework.spring-tx @@ -810,7 +810,7 @@ indirect: true resolvedIdentifier: 98be572c2bf3bd08724363b0bba71bcef59c4739 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/springframework/spring-tx/5.3.7 - name: org.springframework.spring-beans @@ -819,7 +819,7 @@ indirect: true resolvedIdentifier: 8b1eacd7aaa12f7d173a2f0836d28bd0c1b098fe labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/springframework/spring-beans/5.3.7 - name: org.springframework.spring-core @@ -828,7 +828,7 @@ indirect: true resolvedIdentifier: 4aad1b62bd347a806fe693c9d67b376a3ad8151c labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/springframework/spring-core/5.3.7 - name: org.springframework.spring-jcl @@ -837,7 +837,7 @@ indirect: true resolvedIdentifier: ccd8bde38bad689737295fa220e1c70680676d72 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/springframework/spring-jcl/5.3.7 - name: org.aspectj.aspectjrt @@ -846,7 +846,7 @@ indirect: true resolvedIdentifier: 1651849d48659e5703adc2599e694bf67b8c3fc4 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/aspectj/aspectjrt/1.9.6 - name: org.slf4j.slf4j-api @@ -855,7 +855,7 @@ indirect: true resolvedIdentifier: 77100a62c2e6f04b53977b9f541044d7d722693d labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/slf4j/slf4j-api/1.7.26 - name: com.fasterxml.jackson.core.jackson-databind @@ -863,7 +863,7 @@ type: compile resolvedIdentifier: d6153f8fc60c479ab0f9efb35c034526436a4953 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.12.3 - name: com.fasterxml.jackson.core.jackson-annotations @@ -872,7 +872,7 @@ indirect: true resolvedIdentifier: 7275513412694a1aafd08c0287f48469fa0e6e17 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.12.3 - name: com.fasterxml.jackson.core.jackson-core @@ -880,7 +880,7 @@ type: compile resolvedIdentifier: deb23fe2a7f2b773e18ced2b50d4acc1df8fa366 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.12.3 - name: org.apache.tomcat.tomcat-servlet-api @@ -888,7 +888,7 @@ type: provided resolvedIdentifier: 8e8a27a3456b71b1da2c8adc902ade71bc91fcb4 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/apache/tomcat/tomcat-servlet-api/9.0.46 - fileURI: file:///analyzer-lsp/examples/java/pom.xml @@ -926,7 +926,7 @@ indirect: true resolvedIdentifier: 7198b3aac15285a49e218e08441c5f70af00fc51 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.13.3 - name: io.fabric8.kubernetes-model-rbac @@ -1097,7 +1097,7 @@ indirect: true resolvedIdentifier: 6c62681a2f655b49963a5983b8b0950a6120ae14 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/slf4j/slf4j-api/1.7.36 - name: com.fasterxml.jackson.dataformat.jackson-dataformat-yaml @@ -1106,7 +1106,7 @@ indirect: true resolvedIdentifier: 9363ded5441b1fee62d5be0604035690ca759a2a labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/com/fasterxml/jackson/dataformat/jackson-dataformat-yaml/2.13.3 - name: org.yaml.snakeyaml @@ -1115,7 +1115,7 @@ indirect: true resolvedIdentifier: 8fde7fe2586328ac3c68db92045e1c8759125000 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/yaml/snakeyaml/1.30 - name: com.fasterxml.jackson.datatype.jackson-datatype-jsr310 @@ -1124,7 +1124,7 @@ indirect: true resolvedIdentifier: ad2f4c61aeb9e2a8bb5e4a3ed782cfddec52d972 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.13.3 - name: com.fasterxml.jackson.core.jackson-databind @@ -1133,7 +1133,7 @@ indirect: true resolvedIdentifier: 56deb9ea2c93a7a556b3afbedd616d342963464e labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.13.3 - name: com.fasterxml.jackson.core.jackson-core @@ -1142,7 +1142,7 @@ indirect: true resolvedIdentifier: a27014716e4421684416e5fa83d896ddb87002da labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.13.3 - name: io.fabric8.kubernetes-client @@ -1168,7 +1168,7 @@ indirect: true resolvedIdentifier: d3e1ce1d2b3119adf270b2d00d947beb03fe3321 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/com/squareup/okhttp3/okhttp/3.12.12 - name: com.squareup.okio.okio @@ -1177,7 +1177,7 @@ indirect: true resolvedIdentifier: bc28b5a964c8f5721eb58ee3f3c47a9bcbf4f4d8 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/com/squareup/okio/okio/1.15.0 - name: com.squareup.okhttp3.logging-interceptor @@ -1186,7 +1186,7 @@ indirect: true resolvedIdentifier: d952189f6abb148ff72aab246aa8c28cf99b469f labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/com/squareup/okhttp3/logging-interceptor/3.12.12 - name: io.fabric8.zjsonpatch @@ -1203,7 +1203,7 @@ type: test resolvedIdentifier: 4e031bb61df09069aeb2bffb4019e7a5034a4ee0 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/junit/junit/4.11 - name: org.hamcrest.hamcrest-core @@ -1212,6 +1212,6 @@ indirect: true resolvedIdentifier: 42a25dc3219429f0e5d060061f71acb49bf010a0 labels: - - konveyor.io/dep-source=internal + - konveyor.io/dep-source=open-source - konveyor.io/language=java prefix: konveyor-jdt://contents/root/.m2/repository/org/hamcrest/hamcrest-core/1.3 diff --git a/demo.Dockerfile b/demo.Dockerfile index 23b21a79..a27d708b 100644 --- a/demo.Dockerfile +++ b/demo.Dockerfile @@ -4,8 +4,7 @@ WORKDIR /analyzer-lsp COPY rule-example.yaml /analyzer-lsp/rule-example.yaml COPY examples /analyzer-lsp/examples -COPY open-source-libs.txt /analyzer-lsp/open-source-libs.txt EXPOSE 16686 -ENTRYPOINT ["sh", "-c", "all-in-one-linux & sleep 5 && konveyor-analyzer && curl -o traces.json http://localhost:16686/api/traces?service=analyzer-lsp"] +ENTRYPOINT ["sh", "-c", "all-in-one-linux &> /dev/null & sleep 5 && konveyor-analyzer --enable-jaeger && curl -o traces.json http://localhost:16686/api/traces?service=analyzer-lsp"] diff --git a/docs/labels.md b/docs/labels.md index 561b322f..023dd357 100644 --- a/docs/labels.md +++ b/docs/labels.md @@ -75,3 +75,32 @@ To group sub-expressions and control precedence using `(` and `)`: ```sh --label-selector="(key1=val1 || key2=val2) && !val3" ``` + +## Dependency Labels + +The analyzer engine adds labels on dependencies. These labels provide additional information about a dependency such as whether it's open-source or internal, programming language, etc. + +Currenty, analyzer adds following labels on dependencies: + +```yaml +labels: +- konveyor.io/dep-source=internal +- konveyor.io/language=java +``` + +### Dependency Label Selector + +Analyzer CLI accepts `--dep-label-selector` option that allows filtering-in / filtering-out incidents generated from a dependency based on the labels. + +For instance, analyzer adds `konveyor.io/dep-source` label on dependencies with a value that identifies whether the dependency is a known open source dependency or not. To exclude incidents for all such open-source dependencies, `--dep-label-selector` can be used as: + +```sh +konveyor-analyzer ... --dep-label-selector !konveyor.io/dep-source=open-source +``` + +The Java provider in analyzer also takes a list of packages to add an exclude label. To exclude all such packages, `--dep-label-selector` can be used as: + +```sh +konveyor-analyzer ... --dep-label-selector !konveyor.io/exclude +``` + diff --git a/docs/providers.md b/docs/providers.md index 71c0e5a3..491b0fd9 100644 --- a/docs/providers.md +++ b/docs/providers.md @@ -80,7 +80,11 @@ Here's an example config for `java` provider that is currently in-tree and does "bundles": "/path/to/extension/bundles", "workspace": "/path/to/workspace", "depOpenSourceLabelsFile": "/usr/local/etc/maven.default.index", - "mavenSettingsFile": "/path/to/maven/settings/file" + "mavenSettingsFile": "/path/to/maven/settings/file", + "excludePackages": [ + "package1.test", + "package2.test" + ], } } ] @@ -95,9 +99,11 @@ The `java` provider also takes following options in `providerSpecificConfig`: * `workspace`: Path to directory where the provider generates debug information such as logs. -* `depOpenSourceLabelsFile`: Path to a text file, that contains the regex's per line to be added as open-source dependencies. +* `depOpenSourceLabelsFile`: Path to a text file, that contains the regex's per line to be added as open-source dependencies. The base image already contains a default file at `/usr/local/etc/maven.default.index`. -* `mavenSettingsFile`: Path to maven settings file (settings.xml) to use +* `mavenSettingsFile`: Path to maven settings file (settings.xml) to use. + +* `excludePackages`: List of dependency packages on which to add exclude label. #### Builtin Provider diff --git a/provider_container_settings.json b/provider_container_settings.json index fae1f37b..c1988a1f 100644 --- a/provider_container_settings.json +++ b/provider_container_settings.json @@ -29,6 +29,7 @@ "location": "examples/customers-tomcat-legacy", "providerSpecificConfig": { "lspServerPath": "/jdtls/bin/jdtls", + "depOpenSourceLabelsFile": "/usr/local/etc/maven.default.index", "bundles": "/jdtls/java-analyzer-bundle/java-analyzer-bundle.core/target/java-analyzer-bundle.core-1.0.0-SNAPSHOT.jar" }, "analysisMode": "source-only"