Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Fix for issue with initial-input in org-ql-view--complete-buffers-files (Fix #227) #228
Fix for issue with initial-input in org-ql-view--complete-buffers-files (Fix #227) #228
Changes from 11 commits
7b990e5
7120b63
89b8476
cc6e22d
06bdfc7
b68d836
cabf88e
788951a
ffaebcb
564d491
aa9c6cc
cea1651
576f9d3
2d49745
d8f2922
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you change these errors? These are important safety tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had added a explicit error when the input to the
org-ql-view--expand-buffers-files
function,org-ql/org-ql-view.el
Line 1108 in 564d491
According to my understanding, the previous errors being tested were because of the
pcase
failing. So roll back the error I triggering and thepacse
to fail which would lead to the older errors?Even then, in this implementation the return value is always a list, which makes the error being produced to be a bit different than what it previously had.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you mean. Do you understand the potential security issue here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify, the potential values for the
org-ql-view--expand-buffers-files
now are the following:I am also converting all buffer objects to string values to avoid duplicates that are introduced because of the buffer/buffer-name of a file and a file-name being passed.
As a result this function now always returns a list of strings (or at least should, will add tests for these :D).
This is in part due to moving to using
completing-read-multiple
which returns a list by default. Because of this, I had dropped thelistp
predicate in thepcase
inside the function since now all elements in the list are being processed individually. This in-turn results in the unsafe values for buffers/files being tested in the link safety section never getting to the point where that error gets signalled since they never match any of the values in the current pcase. Which was why I was signalling an error when an invalid value is passed. Does this make sense?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may have overlooked that functions are a valid input to
buffers-files
inorg-ql-select
. Which might be creating a whole bunch of new problems :)Currently (in the master branch) the following should create a view with the function
with the value for
org-ql-view-buffers-files
is set to#'a-function-returning-list-of-files
.If I understand this correctly, this is left as such so refreshing the view would recall the function? (or alternatively the evaluated value can be stored?)
I am not sure how a function would translate to a value in
completing-read-mulitple
, so I am skipping prompting for that entirely when refreshing a view with a function as a value fororg-ql-view-buffers-files
.The safety concern you were referring to before comes from allowing a function to be used as a parameter for
org-ql-select
? Currently theorg-ql-view--expand-buffers-files
function would signal an error if used with a function, and when storing a link, the function's evaled value is used forbuffers-files
.Does that cover the problem with unsafe values for
buffers-files
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can see where the error is signaled here:
org-ql/org-ql-view.el
Line 638 in 94f9e6f
That safety check should be left there, in that function, where links are followed. IIUC, the change you made to the tests would cause that check to not be tested, which could lead to security vulnerabilities in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That check looks at either the value returned by the
org-ql-view--expand-buffers-files
or the current-buffer. If I understand it correctly, it was there to make sure the value returned by theorg-ql-view--expand-buffers-files
function is not another function that can get evaluated once passed toorg-ql-select
. Currently, if I understand when and howorg-ql-view--expand-buffers-files
gets called, in a valid situation, it only should get values that I had previously mentioned, anything else would result in the error on the new tests being signaled.If the concern is future changes to the
org-ql-view--expand-buffers-files
function results in returning a function value, that function can be mocked to make sure the error inorg-ql/org-ql-view.el
Line 638 in 94f9e6f
get's signaled?