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

434 template paths #592

Closed
wants to merge 5 commits into from
Closed

434 template paths #592

wants to merge 5 commits into from

Conversation

mburri
Copy link
Member

@mburri mburri commented Jan 22, 2021

Validate the specified path for the template. Absolute paths starting with "/" and path traversals "../" are not allowed.

I allowed myself to add some wrapper methods in order to be able to write some unit tests and slightly refactor the save() method (mostly for readability)

fixes #434

@mburri mburri requested a review from yvespp January 22, 2021 08:47
@yvespp yvespp added this to the Version 1.17.23 milestone Feb 2, 2021
@yvespp
Copy link
Member

yvespp commented Feb 2, 2021

@mburri would it be better to move this validation to the business module? Else it has to be reimplemented for rest/angular again.

@mburri
Copy link
Member Author

mburri commented Mar 1, 2021

@yvespp moving the logic to business-module makes sense.
I'm not sure about the best way to handle the permission check. There is one in the EditTemplateView itself:

And one in the bussiness-module but only for templates for relations:
https://github.com/liimaorg/liima/blob/master/AMW_business/src/main/java/ch/puzzle/itc/mobiliar/business/template/boundary/TemplateEditor.java#L134

There is no permission check in the TemplateEditor for the other possible types (ResourceType/ Resource), see:

I tried to move these to the template editor (different branch) but abandoned it for now because it became a really big change...

I think the simplest change would be to keep the permission check in EditTemplateView and move the template path validation to the TemplateEditor - or what do you think?

@mburri
Copy link
Member Author

mburri commented Mar 1, 2021

I moved the permission checks for resources and resource types to the template editor (see branch 434-template-paths-permission-check-explorations) - but i got quite confused by the method TemplateEditor#saveTemplateForRelation that already does check permissions - but in a different way than EditTemplateView#canModifyTemplates()

Further investigations revealed, that the permission checks to create/ update templates for resource, resourcetypes and/ or resource relation (that seem to fall back to resources or resource types) are also covered by annotations. The specific implementations are necessary to distinguish between create/ update a template.

What is the preferred way for permission checks in Liima:

  • Annotations in the business-module
  • Custom Logic/ throwing Exceptions in the business-module
  • Custom Logic/ throwing Exceptions in the web-module (see EditTemplateView#canModifyTemplates())

Personally, I'd like to use annotations where possible.

@yvespp
Copy link
Member

yvespp commented Mar 1, 2021

Via annotations is fine. For complicated checks it's probably easier in code.

@mburri
Copy link
Member Author

mburri commented Mar 3, 2021

I'm closing this issue without merging in favor of #595

@mburri mburri closed this Mar 3, 2021
@yvespp yvespp deleted the 434-template-paths branch May 27, 2021 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prevent that templates can be writen outside of generation directory
2 participants