jenkinsci / report-jtreg-plugin

Jenkins plugin to show JCK reports
https://plugins.jenkins.io/report-jtreg/
MIT License
1 stars 13 forks source link

Quality of Life/Efficiency/Security Changes #21

Closed patrikcerbak closed 5 months ago

patrikcerbak commented 5 months ago

Quality of Life/Efficiency/Security Changes

From the outside, nothing changes/nothing breaks (hopefully). No new arguments were added, no anything, just inside changes.

Separating filtering jobs from filtering builds

Till now, when the user wanted to filter the jobs with --job-config-find, the filtering was done in the Builds.java class together when filtering individual builds of all jobs - this was really unnecessarily inefficient.

I decided to create a class JobConfigFilter whose aim is to filter the jobs when user uses --job-config-find and Builds.java then gets the already filtered subset, so it can only filter the builds of the matched jobs (not all jobs like before), so it should be quicker.

Everything stays the same, no new command line switch was added, the results of the filtering are still the same, just faster.

Updated Jenkins help

As the heading says, I added two lines to help :)

Reworked the detection of escaping parent directory

Now, instead of checking with regex whether the file location is using ../, there is a new static method ConfigFinder.checkIfConfigIsInParent(), which checks if a config file is inside a given parent directory and if not, it throws an exception. This method is then used where it makes sense before creating new ConfigFinder -> BuildReportExtendedPlugin.java, Builds.java, JobConfigFilter.java.

judovana commented 5 months ago

Hi! Nice job. Can you please add tests for the directory escaping?

judovana commented 5 months ago

pls, fix the test. Create the directory strucutre @beforeach and/or @before - as you will see it suitable. Put all passing tests to one @org.junit.Test and the failing, each to ech own methd @org.junit.Test(expects exception.class) (I'm not sure with proepr wording, but you will find. TY!

Whether to move it to its own file or not, is up to you. TY@!