NOTE: To add some additional context on this issue
[dzager] I don't want to delete any of the description because as it's useful to describe what all is going on but MTA-3594 covers the portion of this issue when the `–rules` argument is passed. This issue will cover the scenarios where `–rules` argument is not given.
Essentially what is happening when the `–rules` argument is not provided is that we are relying on the default ruleset...but Kantra disables the default ruleset when the application contains no Java (this is because the default ruleset currently only contains Java rules).
To fix this, we need to fail early in the case the `–rules` argument is left off and Java is not in the list of providers we will start.
Description of problem:
In MacOS and Linux .NET analysis fails if the user provides a target
abrugaro@fedora:~/bin$ mta-cli-710-22 analyze --input ../apps/dotnet-HelloWorld/ --output ~/Desktop/delete --overwrite --target dotnet8 /usr/bin/podman run --rm --name GUmUUgoMpLmeRpOZ --entrypoint /usr/local/bin/mta-cli --env RUN_MODE=container registry.redhat.io/mta/mta-cli-rhel9:7.1.0 analyze --list-targetsbpOIvHtymSutljho CSkSnGbNNPALEqQp INFO[0000] starting first provider provider=dotnet /usr/bin/podman run -d --rm --name zUfZBpSlaNACrpLP --network bpOIvHtymSutljho -v CSkSnGbNNPALEqQp:/opt/input/source:z registry.redhat.io/mta/mta-dotnet-external-provider-rhel8:7.1.0 --port=457330ad387c50de9b8b335e12cff0cbe49407a26e2277086230ee67ec5edcf823b7c INFO[0000] running source code analysis args="--provider-settings=/opt/input/config/settings.json --output-file=/opt/output/output.yaml --context-lines=100 --verbose=4 --label-selector=((konveyor.io/target=dotnet8) && konveyor.io/source) || (discovery)" input=/home/abrugaro/apps/dotnet-HelloWorld log=/home/abrugaro/Desktop/delete/analysis.log output=/home/abrugaro/Desktop/delete volumes="{\"/home/abrugaro/Desktop/delete\":\"/opt/output\",\"/tmp/analyze-config-3947141557\":\"/opt/input/config\",\"/tmp/m2-repo-2455503495\":\"/root/.m2\",\"CSkSnGbNNPALEqQp\":\"/opt/input/source\"}" INFO[0000] generating analysis log in file file=/home/abrugaro/Desktop/delete/analysis.log /usr/bin/podman run --rm --name zvnepiZdpqZlpLBZ --network container:zUfZBpSlaNACrpLP --entrypoint /usr/local/bin/konveyor-analyzer -v CSkSnGbNNPALEqQp:/opt/input/source:z -v /home/abrugaro/Desktop/delete:/opt/output:z -v /tmp/analyze-config-3947141557:/opt/input/config:z -v /tmp/m2-repo-2455503495:/root/.m2:z registry.redhat.io/mta/mta-cli-rhel9:7.1.0 --provider-settings=/opt/input/config/settings.json --output-file=/opt/output/output.yaml --context-lines=100 --verbose=4 --label-selector=((konveyor.io/target=dotnet8) && konveyor.io/source) || (discovery)ERRO[0000] container run error error="exit status 1" ERRO[0000] failed to run analysis error="time=\"2024-08-01T14:12:47Z\" level=error msg=\"failed to validate flags\" error=\"unable to find rule path or file\"\nError: unable to find rule path or file\nUsage:\n konveyor-analyzer [flags]\n\nFlags:\n --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\n --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)\n --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\n --dep-output-file string path to dependency output file\n --enable-jaeger enable tracer exports to jaeger endpoint\n --error-on-violation exit with 3 if any violation are found will also print violations to console\n --get-openapi-spec string Get the openAPI spec for the rulesets, rules and provider capabilities and put in file passed in.\n -h, --help help for konveyor-analyzer\n --incident-selector string an expression to select incidents based on custom variables. ex: (!package=io.konveyor.demo.config-utils)\n --jaeger-endpoint string jaeger endpoint to collect tracing data (default \"http://localhost:14268/api/traces\")\n --label-selector string an expression to select rules based on labels\n --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)\n --limit-incidents int Set this to the limit incidents that a given rule can give, zero means no limit (default 1500)\n --no-dependency-rules Disable dependency analysis rules\n --output-file string filepath to to store rule violations (default \"output.yaml\")\n --provider-settings string path to the provider settings (default \"provider_settings.json\")\n --rules stringArray filename or directory containing rule files (default [rule-example.yaml])\n --tree output dependencies as a tree\n --verbose int level for logging output (default 9)\n\n" Error: time="2024-08-01T14:12:47Z" level=error msg="failed to validate flags" error="unable to find rule path or file" Error: unable to find rule path or file Usage: konveyor-analyzer [flags] 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 --dep-output-file string path to dependency output file --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 --get-openapi-spec string Get the openAPI spec for the rulesets, rules and provider capabilities and put in file passed in. -h, --help help for konveyor-analyzer --incident-selector string an expression to select incidents based on custom variables. ex: (!package=io.konveyor.demo.config-utils) --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]) --tree output dependencies as a tree --verbose int level for logging output (default 9)
In MacOS and Linux .NET analysis fails if don't provide a target nor rules
abrugaro@fedora:~/bin$ mta-cli-710-22 analyze --input ../apps/dotnet-HelloWorld/ --output ~/Desktop/delete --overwrite erGTNQdqVHrVpUJf DTaTqJXnHNAhbxyY INFO[0000] starting first provider provider=dotnet /usr/bin/podman run -d --rm --name hUUMYrBCsvBvKmuE --network erGTNQdqVHrVpUJf -v DTaTqJXnHNAhbxyY:/opt/input/source:z registry.redhat.io/mta/mta-dotnet-external-provider-rhel8:7.1.0 --port=335011859db027da12bce7d5d5339fb858fd7f1a974a947f30bf17d60c1231bef6fb2 INFO[0000] running source code analysis args="--provider-settings=/opt/input/config/settings.json --output-file=/opt/output/output.yaml --context-lines=100 --verbose=4" input=/home/abrugaro/apps/dotnet-HelloWorld log=/home/abrugaro/Desktop/delete/analysis.log output=/home/abrugaro/Desktop/delete volumes="{\"/home/abrugaro/Desktop/delete\":\"/opt/output\",\"/tmp/analyze-config-1625729185\":\"/opt/input/config\",\"/tmp/m2-repo-1151154814\":\"/root/.m2\",\"DTaTqJXnHNAhbxyY\":\"/opt/input/source\"}" INFO[0000] generating analysis log in file file=/home/abrugaro/Desktop/delete/analysis.log /usr/bin/podman run --rm --name HuqmVAwlJsBatcTV --network container:hUUMYrBCsvBvKmuE --entrypoint /usr/local/bin/konveyor-analyzer -v DTaTqJXnHNAhbxyY:/opt/input/source:z -v /home/abrugaro/Desktop/delete:/opt/output:z -v /tmp/m2-repo-1151154814:/root/.m2:z -v /tmp/analyze-config-1625729185:/opt/input/config:z registry.redhat.io/mta/mta-cli-rhel9:7.1.0 --provider-settings=/opt/input/config/settings.json --output-file=/opt/output/output.yaml --context-lines=100 --verbose=4ERRO[0000] container run error error="exit status 1" ERRO[0000] failed to run analysis error="time=\"2024-08-01T14:13:11Z\" level=error msg=\"failed to validate flags\" error=\"unable to find rule path or file\"\nError: unable to find rule path or file\nUsage:\n konveyor-analyzer [flags]\n\nFlags:\n --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\n --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)\n --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\n --dep-output-file string path to dependency output file\n --enable-jaeger enable tracer exports to jaeger endpoint\n --error-on-violation exit with 3 if any violation are found will also print violations to console\n --get-openapi-spec string Get the openAPI spec for the rulesets, rules and provider capabilities and put in file passed in.\n -h, --help help for konveyor-analyzer\n --incident-selector string an expression to select incidents based on custom variables. ex: (!package=io.konveyor.demo.config-utils)\n --jaeger-endpoint string jaeger endpoint to collect tracing data (default \"http://localhost:14268/api/traces\")\n --label-selector string an expression to select rules based on labels\n --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)\n --limit-incidents int Set this to the limit incidents that a given rule can give, zero means no limit (default 1500)\n --no-dependency-rules Disable dependency analysis rules\n --output-file string filepath to to store rule violations (default \"output.yaml\")\n --provider-settings string path to the provider settings (default \"provider_settings.json\")\n --rules stringArray filename or directory containing rule files (default [rule-example.yaml])\n --tree output dependencies as a tree\n --verbose int level for logging output (default 9)\n\n" Error: time="2024-08-01T14:13:11Z" level=error msg="failed to validate flags" error="unable to find rule path or file" Error: unable to find rule path or file Usage: konveyor-analyzer [flags] 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 --dep-output-file string path to dependency output file --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 --get-openapi-spec string Get the openAPI spec for the rulesets, rules and provider capabilities and put in file passed in. -h, --help help for konveyor-analyzer --incident-selector string an expression to select incidents based on custom variables. ex: (!package=io.konveyor.demo.config-utils) --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]) --tree output dependencies as a tree --verbose int level for logging output (default 9)
In MacOS .NET analysis fails if I provide --rules (this works on linux)
ec2-user@ip-172-31-25-249:~/bin$ ./darwin-mta-cli analyze --input ../apps --output ./report --overwrite --rules ../rules/ --log-level 10 DEBU[0000] created directory for XML rules dir=/var/folders/nm/xdlnygrs08n5gv_g4s281jzh0000gn/T/transform-rules-3471873886 DEBU[0000] created directory for converted XML rules dir=/var/folders/nm/xdlnygrs08n5gv_g4s281jzh0000gn/T/transform-output-2978366523 INFO[0000] running windup shim args="convert --outputdir=/opt/shimoutput /opt/xmlrules" output=/Users/ec2-user/bin/report volumes="{\"../rules/\":\"/opt/xmlrules/rules\",\"/var/folders/nm/xdlnygrs08n5gv_g4s281jzh0000gn/T/transform-output-2978366523\":\"/opt/shimoutput\"}" INFO[0000] generating shim log in file file=/Users/ec2-user/bin/report/shim.log /usr/local/bin/podman run --rm --name BoNYTIlmsTOPxgwI --entrypoint /usr/local/bin/windup-shim -v /var/folders/nm/xdlnygrs08n5gv_g4s281jzh0000gn/T/transform-output-2978366523:/opt/shimoutput -v ../rules:/opt/xmlrules/rules registry.redhat.io/mta/mta-cli-rhel9:7.1.0 convert --outputdir=/opt/shimoutput /opt/xmlrulesDEBU[0000] executing command args="run --rm --name BoNYTIlmsTOPxgwI --entrypoint /usr/local/bin/windup-shim -v /var/folders/nm/xdlnygrs08n5gv_g4s281jzh0000gn/T/transform-output-2978366523:/opt/shimoutput -v ../rules:/opt/xmlrules/rules registry.redhat.io/mta/mta-cli-rhel9:7.1.0 convert --outputdir=/opt/shimoutput /opt/xmlrules" cmd=/usr/local/bin/windup-shim container tool=/usr/local/bin/podman ERRO[0000] container run error error="exit status 125" ERRO[0000] failed to convert xml rules error="Error: statfs /var/home/rules: no such file or directory\n" Error: Error: statfs /var/home/rules: no such file or directory
Version-Release number of selected component (if applicable): mta-operator-bundle-container-7.1.0-43
How reproducible: Always
Steps to Reproduce:
1. Run the following command
./darwin-mta-cli analyze --input ../apps --output ./report --overwrite --target dotnet3 --log-level 10
The app used is https://github.com/konveyor/analyzer-lsp/tree/main/external-providers/dotnet-external-provider/examples/HelloWorld
Actual results:
ec2-user@ip-172-31-25-249:~/bin$ ./darwin-mta-cli analyze --input ../apps --output ./report --overwrite --target dotnet3 --log-level 10 /usr/local/bin/podman run --rm --name rKooECYAyxIBAkxc --entrypoint /usr/local/bin/mta-cli --env RUN_MODE=container registry.redhat.io/mta/mta-cli-rhel9:7.1.0 analyze --list-targetsDEBU[0000] executing command args="run --rm --name rKooECYAyxIBAkxc --entrypoint /usr/local/bin/mta-cli --env RUN_MODE=container registry.redhat.io/mta/mta-cli-rhel9:7.1.0 analyze --list-targets" cmd=/usr/local/bin/mta-cli container tool=/usr/local/bin/podman UNKN[0000] Got language component language="{\"Name\":\"C#\",\"Aliases\":[\"csharp\",\"dotnet\",\".NET\"],\"Weight\":100,\"Frameworks\":[\"net8.0\"],\"Tools\":[],\"CanBeComponent\":true,\"CanBeContainerComponent\":false}" ZjyXTZsMpkumBoap DEBU[0000] created container network network=ZjyXTZsMpkumBoap AqwgosXkqlsxhGHj DEBU[0001] created container volume volume=AqwgosXkqlsxhGHj INFO[0001] starting first provider provider=dotnet /usr/local/bin/podman run -d --rm --name PYKUsWesQeEcxSBY --network ZjyXTZsMpkumBoap -v AqwgosXkqlsxhGHj:/opt/input/source registry.redhat.io/mta/mta-dotnet-external-provider-rhel8:7.1.0 --port=49941DEBU[0001] executing command args="run -d --rm --name PYKUsWesQeEcxSBY --network ZjyXTZsMpkumBoap -v AqwgosXkqlsxhGHj:/opt/input/source registry.redhat.io/mta/mta-dotnet-external-provider-rhel8:7.1.0 --port=49941" cmd= container tool=/usr/local/bin/podman b9d915e1ba78f5459e9c4a403fbb1e574c32d63163ea79b593a1797697d56ecf DEBU[0002] created directory for provider settings dir=/var/folders/nm/xdlnygrs08n5gv_g4s281jzh0000gn/T/analyze-config-1632877261 UNKN[0002] provider options config not found, using default options INFO[0002] running source code analysis args="--provider-settings=/opt/input/config/settings.json --output-file=/opt/output/output.yaml --context-lines=100 --verbose=10 --label-selector=((konveyor.io/target=dotnet3) && konveyor.io/source) || (discovery)" input=/Users/ec2-user/apps log=/Users/ec2-user/bin/report/analysis.log output=/Users/ec2-user/bin/report volumes="{\"/Users/ec2-user/bin/report\":\"/opt/output\",\"/var/folders/nm/xdlnygrs08n5gv_g4s281jzh0000gn/T/analyze-config-1632877261\":\"/opt/input/config\",\"AqwgosXkqlsxhGHj\":\"/opt/input/source\"}" INFO[0002] generating analysis log in file file=/Users/ec2-user/bin/report/analysis.log /usr/local/bin/podman run --rm --name KogNBPQZkyITNSJM --network container:PYKUsWesQeEcxSBY --entrypoint /usr/local/bin/konveyor-analyzer -v AqwgosXkqlsxhGHj:/opt/input/source -v /Users/ec2-user/bin/report:/opt/output -v /var/folders/nm/xdlnygrs08n5gv_g4s281jzh0000gn/T/analyze-config-1632877261:/opt/input/config registry.redhat.io/mta/mta-cli-rhel9:7.1.0 --provider-settings=/opt/input/config/settings.json --output-file=/opt/output/output.yaml --context-lines=100 --verbose=10 --label-selector=((konveyor.io/target=dotnet3) && konveyor.io/source) || (discovery)DEBU[0002] executing command args="run --rm --name KogNBPQZkyITNSJM --network container:PYKUsWesQeEcxSBY --entrypoint /usr/local/bin/konveyor-analyzer -v AqwgosXkqlsxhGHj:/opt/input/source -v /Users/ec2-user/bin/report:/opt/output -v /var/folders/nm/xdlnygrs08n5gv_g4s281jzh0000gn/T/analyze-config-1632877261:/opt/input/config registry.redhat.io/mta/mta-cli-rhel9:7.1.0 --provider-settings=/opt/input/config/settings.json --output-file=/opt/output/output.yaml --context-lines=100 --verbose=10 --label-selector=((konveyor.io/target=dotnet3) && konveyor.io/source) || (discovery)" cmd=/usr/local/bin/konveyor-analyzer container tool=/usr/local/bin/podman ERRO[0002] container run error error="exit status 1" ERRO[0002] failed to run analysis error="time=\"2024-08-01T13:18:48Z\" level=error msg=\"failed to validate flags\" error=\"unable to find rule path or file\"\nError: unable to find rule path or file\nUsage:\n konveyor-analyzer [flags]\n\nFlags:\n --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\n --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)\n --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\n --dep-output-file string path to dependency output file\n --enable-jaeger enable tracer exports to jaeger endpoint\n --error-on-violation exit with 3 if any violation are found will also print violations to console\n --get-openapi-spec string Get the openAPI spec for the rulesets, rules and provider capabilities and put in file passed in.\n -h, --help help for konveyor-analyzer\n --incident-selector string an expression to select incidents based on custom variables. ex: (!package=io.konveyor.demo.config-utils)\n --jaeger-endpoint string jaeger endpoint to collect tracing data (default \"http://localhost:14268/api/traces\")\n --label-selector string an expression to select rules based on labels\n --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)\n --limit-incidents int Set this to the limit incidents that a given rule can give, zero means no limit (default 1500)\n --no-dependency-rules Disable dependency analysis rules\n --output-file string filepath to to store rule violations (default \"output.yaml\")\n --provider-settings string path to the provider settings (default \"provider_settings.json\")\n --rules stringArray filename or directory containing rule files (default [rule-example.yaml])\n --tree output dependencies as a tree\n --verbose int level for logging output (default 9)\n\n" DEBU[0002] removing temp dirs DEBU[0002] stopping container container=PYKUsWesQeEcxSBY DEBU[0003] removing container network network=ZjyXTZsMpkumBoap DEBU[0003] removing created volume volume=AqwgosXkqlsxhGHj Error: time="2024-08-01T13:18:48Z" level=error msg="failed to validate flags" error="unable to find rule path or file" Error: unable to find rule path or file Usage: konveyor-analyzer [flags] 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 --dep-output-file string path to dependency output file --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 --get-openapi-spec string Get the openAPI spec for the rulesets, rules and provider capabilities and put in file passed in. -h, --help help for konveyor-analyzer --incident-selector string an expression to select incidents based on custom variables. ex: (!package=io.konveyor.demo.config-utils) --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]) --tree output dependencies as a tree --verbose int level for logging output (default 9)
Expected results:
The analysis should complete successfully and the static report should be generated.