-
Notifications
You must be signed in to change notification settings - Fork 52
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
Updated NeLS Integration #2167
base: main
Are you sure you want to change the base?
Updated NeLS Integration #2167
Conversation
Waiting on create dataset, upload metadata API support
waiting for info before finishing off
# Conflicts: # app/controllers/nels_controller.rb # config/version.yml # docker-compose.yml
# Conflicts: # docker-compose.yml
# Conflicts: # app/assets/stylesheets/application.css
raise Nels::Rest::Client::FetchFileError, 'temp copy of file doesnt exist' unless File.exist?(path) | ||
|
||
# send_data blocks and allows the file to be cleaned up afterwards | ||
File.open(path, 'r') do |f| |
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression High
user-provided value
This autofix suggestion was applied.
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 11 days ago
To fix the problem, we need to ensure that the key
parameter is properly validated and sanitized to prevent any form of path manipulation. We can achieve this by using a whitelist approach to only allow known good patterns for the key
parameter. Additionally, we should ensure that the path
is constructed in a way that prevents directory traversal attacks.
The best way to fix the problem is to:
- Validate the
key
parameter using a strict whitelist of allowed characters. - Ensure that the
path
is constructed in a secure manner that prevents directory traversal.
-
Copy modified line R148 -
Copy modified lines R151-R152
@@ -147,8 +147,7 @@ | ||
|
||
unless key =~ /^[0-9a-z-]+$/ | ||
unless key =~ /\A[0-9a-z-]+\z/ | ||
raise Nels::Rest::Client::FetchFileError, 'Invalid file key' | ||
end | ||
sanitized_key = key.gsub(/[^0-9a-z-]/, '') | ||
path = File.join("/tmp", "nels-download-#{sanitized_key}") | ||
raise Nels::Rest::Client::FetchFileError, 'temp copy of file doesnt exist' unless File.exist?(path) | ||
path = File.join("/tmp", "nels-download-#{key}") | ||
raise Nels::Rest::Client::FetchFileError, 'temp copy of file doesnt exist' unless File.exist?(path) && path.start_with?("/tmp/nels-download-") | ||
|
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
No description provided.