Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFE] Dynamic File-Based Input for Rules #192

Open
brunoborges opened this issue Jul 30, 2024 · 7 comments
Open

[RFE] Dynamic File-Based Input for Rules #192

brunoborges opened this issue Jul 30, 2024 · 7 comments
Labels
needs-kind Indicates an issue or PR lacks a `kind/foo` label and requires one. needs-priority Indicates an issue or PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@brunoborges
Copy link

Enable Konveyor / Kantra to accept files as input to rules, allowing these files to be parsed and utilized as dynamic input parameters. This feature would enhance flexibility by supporting the inclusion of various data formats (e.g., JSON, YAML, CSV) for rule execution. Users could upload a configuration or data file, which the system would parse to extract necessary parameters, thus allowing more complex and customized rule conditions without manual input. This capability would streamline workflows, especially in scenarios requiring detailed configuration or large data sets.

@konveyor-ci-bot konveyor-ci-bot bot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Jul 30, 2024
@konveyor-ci-bot
Copy link

This issue is currently awaiting triage.
If contributors determine this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.
The triage/accepted label can be added by org members.

@konveyor-ci-bot konveyor-ci-bot bot added needs-kind Indicates an issue or PR lacks a `kind/foo` label and requires one. needs-priority Indicates an issue or PR lacks a `priority/foo` label and requires one. labels Jul 30, 2024
@shawn-hurley
Copy link
Contributor

Hello,

I think that we would only accept xml (run through the shim) and yaml files. today we can accept xml rules if you use the `--rules`` flag.

@shawn-hurley
Copy link
Contributor

actually just tested and you can pass in a yaml file as well:

 analyze --rules ../rulesets/default/generated/cloud-readiness/70-local-storage.windup.yaml --input ../testing-apps/tackle-testapp-public --maven-settings ../settings.xml -o output --overwrite

@shawn-hurley
Copy link
Contributor

Let me know if that will cover the usecase, I am not fully clear on how a CSV would be used and I don't know if we want to go about supporting a different type of rule format.

@brunoborges
Copy link
Author

Well, not really. Let me give you an example of a use case:

Customer has a list of domains/URLs they want to check if they are hardcoded in the source code.

Today, one option is to write a custom rule. Alternatively, we would like to see the ability of the Rule parser to read data from external files in addition to the rule file definition.

Let's look at the localhost rule. Right now, it looks for localhost, but what if we wanted to look for other domains, such as mycompany or staging or prodenv.

when:
    builtin.filecontent:
      filePattern: .*\.(java|properties|jsp|jspf|tag|xml|txt|yaml)
      pattern: http(s)?://((localhost)|(127\.0\.0\.1))+(:[0-9]+)?(/.*)?

In the code above, I'd like to provide a parameter instead of localhost so that it would expand with a list of domains coming from an external file.

Another common scenario is imports.

@shawn-hurley
Copy link
Contributor

Thank you, this feature request is making much more sense to me now!

It sounds like you are asking for some way loop over an external source of some interpolated pattern in the rules, creating new rules from that source for each pattern that is found in the external source.

I'll let @rromannissen weigh in on the priority, but I think I understand the ask now and think that it is worth exploring if the priority is high enough

@rromannissen
Copy link
Contributor

I'm a bit concerned about how this request might affect the concept of rules as "automated pieces of knowledge", as this would leave the door open to some uncertainty about how a rule might behave. By design, rules are expected to be very explicit about the antipatterns to look for and provide a solution for those antipatterns, and if this was implemented, rules could stop being self contained and behave differently depending on certain input at runtime, which could potentially be a bit non deterministic. I totally see how this could be convenient for some custom rules development scenarios, but it would be kind of dangerous for rules that come out of the box with Konveyor, especially for potential downstream distributions, as it would be hard to support those rules if their behavior is not preestablished.

Nevertheless, I would definitely not oppose to this being implemented, but considering that the same results could be achieved at the moment via custom rules by adding additional when criteria entries, I don't think our team would be tackling this on the short to mid term, although we would be open to contributions on this direction.

@rromannissen rromannissen transferred this issue from konveyor/kantra Aug 1, 2024
@rromannissen rromannissen changed the title Feature Request: Dynamic File-Based Input for Rules [RFE] Dynamic File-Based Input for Rules Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-kind Indicates an issue or PR lacks a `kind/foo` label and requires one. needs-priority Indicates an issue or PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
Status: 🆕 New
Development

No branches or pull requests

3 participants