Skip to content

Conversation

jmthomas
Copy link
Member

closes #500

@jmthomas jmthomas requested a review from ryanmelt May 22, 2023 15:11
@codecov
Copy link

codecov bot commented May 22, 2023

Codecov Report

Patch coverage: 25.00% and project coverage change: -0.26 ⚠️

Comparison is base (111e58d) 71.04% compared to head (71a6e01) 70.79%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #678      +/-   ##
==========================================
- Coverage   71.04%   70.79%   -0.26%     
==========================================
  Files         470      471       +1     
  Lines       29992    30213     +221     
  Branches      816      822       +6     
==========================================
+ Hits        21307    21388      +81     
- Misses       8600     8740     +140     
  Partials       85       85              
Flag Coverage Δ
frontend 58.61% <53.65%> (+0.29%) ⬆️
ruby-api 50.64% <10.84%> (-0.72%) ⬇️
ruby-backend 78.13% <ø> (-0.29%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...es/openc3-cosmos-tool-bucketexplorer/src/router.js 100.00% <ø> (ø)
...-cmd-tlm-api/app/controllers/storage_controller.rb 12.61% <7.50%> (-5.17%) ⬇️
...plorer/src/tools/BucketExplorer/BucketExplorer.vue 73.73% <53.65%> (-3.19%) ⬇️
openc3-cosmos-cmd-tlm-api/config/routes.rb 100.00% <100.00%> (ø)

... and 11 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@ryanmelt ryanmelt left a comment

Choose a reason for hiding this comment

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

Changes uses OPENC3_NAME_VOLUME environment as discuss and address path security issue found by CodeQL

volume = ENV[params[:volume]] # Get the actual volume name
raise "Unknown volume #{params[:volume]}" unless volume
filename = "/#{volume}/#{params[:object_id]}"
file = File.read(filename, mode: 'rb')

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

This path depends on a [user-provided value](1).
metadata = params[:metadata].present? ? true : false
results = bucket.list_files(bucket: bucket_name, path: path, metadata: metadata)
root = ENV[params[:root]] # Get the actual bucket / volume name
raise "Unknown bucket / volume #{params[:root]}" unless root
Copy link
Member

Choose a reason for hiding this comment

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

Probably remove params[:root] from this. Could be used to expose any ENV variable.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm simply passing back the parameters passed in the request. They get no additional information except that the environment variable doesn't exist.

Copy link
Member

Choose a reason for hiding this comment

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

Ah ok.

elsif params[:root].include?('_VOLUME')
dirs = []
files = []
list = Dir["/#{root}/#{params[:path].gsub('.', '')}/*"]
Copy link
Member

Choose a reason for hiding this comment

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

You could have . in a real directory name. Like .ssh. Need to do more of an absolute path kind of thing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Didn't think about that. I was trying to avoid going back with ../ or whatever. It's already an absolute path with the leading /. Trying to follow the recommendations here: https://codeql.github.com/codeql-query-help/java/java-path-injection/

Copy link
Member

Choose a reason for hiding this comment

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

I guess its ok, just might burn us at some point in the future.

return unless authorization('system')
volume = ENV[params[:volume]] # Get the actual volume name
raise "Unknown volume #{params[:volume]}" unless volume
filename = "/#{volume}/#{params[:object_id].gsub('.', '')}"
Copy link
Member

Choose a reason for hiding this comment

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

Same comment.

@ryanmelt
Copy link
Member

Just need to fix playwright tests then.

dirs = []
files = []
path = sanitize_path(params[:path])
list = Dir["/#{root}/#{path}/*"] # Ok for path to be blank

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

This path depends on a [user-provided value](1).
@jmthomas jmthomas merged commit 2a5c81f into main May 25, 2023
@jmthomas jmthomas deleted the browse_volumes branch May 25, 2023 13:49
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.

Support browsing volume mounts and gems
2 participants