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

Validate scripts in global <Scripts> container #3176

Open
ppkarwasz opened this issue Nov 5, 2024 · 3 comments
Open

Validate scripts in global <Scripts> container #3176

ppkarwasz opened this issue Nov 5, 2024 · 3 comments
Labels
bug Incorrect, unexpected, or unintended behavior of existing code good first issue Issues that are good for contributors looking to get started

Comments

@ppkarwasz
Copy link
Contributor

The ScriptsPlugin should perform a validation of the script nested configuration elements and:

  • Remove the scripts that do not have a name.
  • Issue a status logger warning, when this condition occurs.
@ppkarwasz ppkarwasz added bug Incorrect, unexpected, or unintended behavior of existing code good first issue Issues that are good for contributors looking to get started labels Nov 5, 2024
@JWT007
Copy link
Contributor

JWT007 commented Nov 5, 2024

Hi @ppkarwasz,

So I was going to fix this but in testing realized that no script is every really created with no name.

The super-constructor for Script/ScriptRef/ScriptFile when passed a null name evaluates a default from toString().

public AbstractScript(final String name, final String language, final String scriptText) {
    this.language = language;
    this.scriptText = scriptText;
    this.name = name == null ? this.toString() : name;
}

Example: org.apache.logging.log4j.core.script.Script@7857fe2.

So by the time the array of scripts shows up in the ScriptsPlugin there are no scripts without names.

It is however a name that probably could never be sensibly referenced.

@JWT007
Copy link
Contributor

JWT007 commented Nov 9, 2024

@ppkarwasz what should be done with this ticket? see last comment.

Of course, the Script builders and AbstractScript constructor can be modified...

@ppkarwasz
Copy link
Contributor Author

@ppkarwasz what should be done with this ticket? see last comment.

Of course, the Script builders and AbstractScript constructor can be modified...

Since AbstractScript.getName() is used extensively accross the code, I believe that we need an additional property (getConfiguredName()?) to allow the ScriptsPlugin to remove the scripts without an explicit name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect, unexpected, or unintended behavior of existing code good first issue Issues that are good for contributors looking to get started
Projects
None yet
Development

No branches or pull requests

2 participants