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

ELY-1206: Added periodic-rotating and size-rotating audit endpoints #845

Merged
merged 3 commits into from Jun 15, 2017

Conversation

yersan
Copy link
Contributor

@yersan yersan commented May 29, 2017

Added two different rotating audit endpoints and removed the old one.

Jira issues:
https://issues.jboss.org/browse/ELY-1206
https://issues.jboss.org/browse/JBEAP-10700

depends on wildfly/wildfly-core#2425

@wildfly-ci
Copy link

Can one of the admins verify this patch?

Copy link
Contributor

@jamezp jamezp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two comments on minor points, but other than that this looks okay to me.

* The suffix must be a string understood by the {@link java.time.format.DateTimeFormatter}.
* <p/>
* <b>Note:</b> Any files rotated with the suffix appended will not be deleted. The {@link #setMaxBackupIndex(int)
* maxBackupIndex} is not used for files with a suffix.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should fix this documentation as it's not quite correct. Files with the same date suffix will be deleted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Override
protected void write(byte[] bytes) throws IOException {
super.write(bytes);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really a big deal, but this could probably just be removed since it's only a super call.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return;
}
closeStreams(); // close the original file (some OSes won't let you move/rename a file that is open)
final Path target = Paths.get(file.getAbsolutePath() + nextSuffix);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this safe on Windows? Maybe it would be safer to instead say something like (from memory):

final Path target = file.toPath().resolve(file.getName() + nextSuffix);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 that's a good point and the above example should work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamezp I have added this modification. Just a minor note, in fact, nextSuffix here can be any pattern if it pass for a DateTimeFormatter, so to avoid possible problems defining suffixes on different operating systems, some characters in the suffix are always replaced by '_'

* @throws IllegalArgumentException if the suffix is not valid
*/
public Builder setSuffix(String suffix) throws IllegalArgumentException {
format = DateTimeFormatter.ofPattern(suffix.replaceAll("[\\/:*?\"<>|]", "_")).withZone(timeZone);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmlloyd What do you think about this? I kind of think we should allow anything as different OS's allow for different characters in their paths.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 This does seem a little over restrictive.

Also at some point this kind of check may be better handled in the management model, i.e. in the model we can either perform MODEL stage validation or correct values.

Copy link
Contributor

@darranl darranl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can loose the manipulation of the name but other than that looks good.

@yersan
Copy link
Contributor Author

yersan commented Jun 2, 2017

@darranl I have removed the file name restrictions when suffix is used

@hkalina
Copy link

hkalina commented Jun 2, 2017

@yersan Did you considered need of combined rollover? Dividing logs by individual days, but with automatic dividing of day's log file to more parts when it is too big in given day?

@yersan
Copy link
Contributor Author

yersan commented Jun 2, 2017

@honza889 It was discussed with @jamezp and @bstansberry, final decision was not to include it here at the moment because this is just for audit and syslog files and there were complaints with that handler because it don't purge rotated files

@hkalina hkalina added the +1 HK label Jun 2, 2017
@jamezp
Copy link
Contributor

jamezp commented Jun 5, 2017

Since we're not using the java.time API we may want to also change the FileAuditEndpoint. setDateFormatSupplier() to accept a java.time.format.DateTimeFormatter.

@darranl
Copy link
Contributor

darranl commented Jun 9, 2017

@yersan what do you think of the last comment from @jamezp are we going to make one more change to this one?

@yersan
Copy link
Contributor Author

yersan commented Jun 9, 2017

@darranl It makes sense for me, FileAuditEndpoint is a class related to Elytron Audit log and target JDK is Java 8. I will add a new commit including it. I will require and additional commit on dependent PR in wfcore too.

@darranl
Copy link
Contributor

darranl commented Jun 9, 2017

Thanks, once that is in I will coordinate the two together.

@yersan
Copy link
Contributor Author

yersan commented Jun 12, 2017

@jamezp @darranl , I have applied the changes to get rid of Java 7 date/time API not only in FileAuditEndpoint, but also in other files related with Audit log. At least for me, it made sense to do it in all of them. WFCore PR was updated according to this change as well. There are no pending changes from my side.

@jamezp
Copy link
Contributor

jamezp commented Jun 12, 2017

Looks good to me. 👍

@darranl darranl added the +1 DAL label Jun 15, 2017
@darranl darranl merged commit 7edae73 into wildfly-security:master Jun 15, 2017
@yersan yersan deleted the bugs/ELY-1206 branch July 3, 2017 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants