eclipse / transformer

Eclipse Transformer provides tools and runtime components that transform Java binaries, such as individual class files and complete JARs and WARs, mapping changes to Java packages, type names, and related resource names.

Home Page:https://projects.eclipse.org/projects/technology.transformer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve input checking for command line execution

11rx4f opened this issue · comments

Environment Details

  • Transformer Version: 0.5.0
  • JDK version: openjdk 11.0.12
  • OS: Red Hat Enterprise Linux 7.4

Problem Description

By adding validation of input values, I want users to be aware of the following two input errors before running the conversion process.

  • If an empty string "" is specified in the argument, the current directory is treated as the input or output path. However, when specifying the current directory as the input value, many users specify dot(.). So specifying consecutive double quotes "" are almost always a typo. Also, as described in the Steps to reproduce, the log becomes difficult to understand. Therefore, it is better to introduce validation of empty strings.
  • If three or more arguments are specified incorrectly, command execution does not result in an error. Therefore, there is a risk of overwriting the original file by mistakenly specifying the argument.
    For example, if the -o option is specified, the first and second arguments incorrectly specify the original conversion target, and the third argument specifies the destination file, the original conversion target will be overwritten.
    This type of operation error can be prevented by adding an argument count validation process.

Steps to reproduce

# java -jar org.eclipse.transformer.cli/target/org.eclipse.transformer.cli-0.5.0-
SNAPSHOT.jar /work/transformer/test ""
Copyright (c) Contributors to the Eclipse Foundation
org.eclipse.transformer.cli.JakartaTransformerCLI Version [ 0.5.0-SNAPSHOT ]

[main] INFO Transformer - Input [ /work/transformer/test ]
[main] INFO Transformer - Output [ /home/k5user/Github/11rx4f/transformer ]
# java -jar org.eclipse.transformer.cli/target/org.eclipse.transformer.cli-0.5.0-SNAPSHOT.jar /work/transformer/test/TestServlet.java /work/transformer/test/TestServlet.java /work/transformer/test/TestServlet.java -o
Copyright (c) Contributors to the Eclipse Foundation
org.eclipse.transformer.cli.JakartaTransformerCLI Version [ 0.5.0-SNAPSHOT ]

[main] INFO Transformer - Input [ /work/transformer/test/TestServlet.java ]
[main] INFO Transformer - Output [ /work/transformer/test/TestServlet.java ]
[main] INFO Transformer - Overwrite of output is enabled
[main] INFO Transformer - Output exists and will be overwritten [ /work/transformer/test/TestServlet.java ]

Cause

There is not enough input value check for both problems.

This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution.

This issue has been automatically closed due to inactivity. If you can reproduce this or if you have a good use case for this feature, please feel free to reopen the issue with steps to reproduce, a quick explanation of your use case or a high-quality pull request.