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

Make DELETE require write permissions on container #1014

Merged

Conversation

rubensworks
Copy link
Contributor

DELETE will now basically always check the permissions of the parent directory.

As requested in #729.

@@ -26,7 +26,7 @@ function LdpMiddleware (corsSettings) {
router.post('/*', allow('Append'), post)
router.patch('/*', allow('Append'), patch)
router.put('/*', allow('Write'), put)
router.delete('/*', allow('Write'), del)
router.delete('/*', allow('Write', '..'), del)
Copy link
Member

Choose a reason for hiding this comment

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

Not sure, but wouldn't ./ be the path to the container?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason why that was needed is because I used path.join, which considers everything to be a path segment, including the filename itself, so ./ would do nothing.

In any case, I rewrote this PR a bit, as it was indeed a bit confusing.

Copy link
Member

Choose a reason for hiding this comment

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

OK; perhaps you can have a look too, @RubenVerborgh ?

Copy link
Contributor

@RubenVerborgh RubenVerborgh left a comment

Choose a reason for hiding this comment

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

Functionality okay, only naming suggestions. Easily testable, or too hard?

const ACL = require('../acl-checker')
const debug = require('../debug.js').ACL
const fs = require('fs')
const { promisify } = require('util')
const HTTPError = require('../http-error')

function allow (mode) {
function allow (mode, testDirectory) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Unclear parameter name IMHO

@@ -23,6 +24,11 @@ function allow (mode) {
? res.locals.path
: req.path

// If a relativePath has been provided, check permissions based on that
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment out of sync?

@@ -23,6 +24,11 @@ function allow (mode) {
? res.locals.path
: req.path

// If a relativePath has been provided, check permissions based on that
if (testDirectory) {
reqPath = path.dirname(reqPath)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe deceptive to use reqPath for it then. Perhaps should be something like resourcePath.

@rubensworks
Copy link
Contributor Author

Easily testable, or too hard?

Too hard in the current architecture. I couldn't find a place where both the allow and delete handlers were already setup in tests, so writing a test for this would require quite a bit of effort (but should be possible to do if we want to invest time in that).

All other comments have been resolved.

@kjetilk kjetilk merged commit 2fbe582 into nodeSolidServer:release/v5.0.0 Dec 10, 2018
@ghost ghost removed the in progress label Dec 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants