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

Fix favorites to consult allowlist #3526

Merged
merged 6 commits into from
Jul 12, 2024
Merged

Fix favorites to consult allowlist #3526

merged 6 commits into from
Jul 12, 2024

Conversation

Oglopf
Copy link
Contributor

@Oglopf Oglopf commented Apr 22, 2024

Fixes #3193

@Oglopf
Copy link
Contributor Author

Oglopf commented Apr 22, 2024

Need to take a look a the DashboardControllerTest#test_should_create_Files_dropdown test.

`mkdir -p #{project_path}`
`mkdir -p #{project_path2}`
# regular directory now though?
#`mkdir -p #{s3_path}`
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you expand more on what you mean by this? The next assertion passes when I uncomment this line, and it's the URLs that are wrong - and the problem there:

Screenshot 2024-05-09 at 10 06 46 AM

Which is what the old assertion was (but then if I change to the old assertion I still get S3 weirdness, so I want to investigate your thoughts behind this being commented out).

p.remote? || p.path.directory? && p.path.readable? && p.path.executable?
Configuration.allowlist_paths.include?(p.path) && (p.remote? || p.path.directory?) && p.path.readable? && p.path.executable?
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is the source of the issues you're having with the tests.

This would evaluate to false. I.e., it does not account for child paths.

['/a'].include?('/a/b') 

I think you need to use Allowlist.default.permitted?(p.path)

Copy link
Contributor

Choose a reason for hiding this comment

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

What is Allowlist here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I replaced Configuration.allowlist_paths.include?(p.path) with AllowlistPolicy.default.permitted?(p.path) and there is still wonkiness with the way the S3 path is expanded in the test.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep you found it - I pulled that from memory, should have been AllowlistPolicy

@Oglopf Oglopf marked this pull request as ready for review May 20, 2024 16:02
HazelGrant
HazelGrant previously approved these changes May 20, 2024
@HazelGrant HazelGrant dismissed their stale review May 23, 2024 13:58

Breaks favorite remote files

Comment on lines 24 to 25
test 'should create Files dropdown' do
scratch_path = File.expand_path 'test/fixtures/dummy_fs/scratch'
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to edit this test case. I just checked out the master version of this file and ran the tests and it passes without modification.

Which is to say, I think we should generally add tests and try not to modify tests. Tests are our safeguards and I think this one ensures that remote filesystems will always appear in the dropdown.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Coming back around to this.

This test will fail on the branch with the change, because the paths scratch_path and project_path are not allowed, so they don't display which caused the previous test failures.

The test case was only altered when the failure showed up after the change. I can change it back, but the tests will fail like on the previous commit:
https://github.com/OSC/ondemand/actions/runs/9004647134/job/24738112032

Copy link
Contributor

Choose a reason for hiding this comment

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

This test will fail on the branch with the change, because the paths scratch_path and project_path are not allowed, so they don't display which caused the previous test failures.

There's no allowlist setting in the original test. What I'm saying is that we should revert it back to what it is in the master branch.

The original test case tests the behavior when no OOD_ALLOWLIST_PATH has been set and I think we should keep that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. I can revert it, what do we do when it fails though?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok. I can revert it, what do we do when it fails though?

I just tested and it passes. But if it fails - then it's doing what it's supposed to: signaling to us that we did something wrong. That's the whole point to test cases - they're guard rails to say that this is the behavior that we want to preserve. If they fail, then we're not preserving that behavior correctly and we need to fix something in the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh my lord, i know what a test is man lol.

I just don't get how this passes with the change, but that's fine. Mark as done and we can finally be done with this infernal code.

@Oglopf Oglopf force-pushed the allowlist-favs-fix branch from ce4f833 to a7bb946 Compare July 8, 2024 17:24
@johrstrom johrstrom self-requested a review July 9, 2024 14:31
@johrstrom johrstrom merged commit 52fd05e into master Jul 12, 2024
23 checks passed
@johrstrom johrstrom deleted the allowlist-favs-fix branch July 12, 2024 13:45
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.

file path favorites outside of allowlist shouldn't show up anywhere
4 participants