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

Allow to generate more informative profile file name #638

Merged
merged 2 commits into from Jan 22, 2023

Conversation

k4rl85
Copy link
Contributor

@k4rl85 k4rl85 commented Jan 3, 2023

The aim of this pull request is to generate a more informative profile file name. This would allow us to identify the endpoint that generates a profile file without the need to open it.

To avoid breaking any existent use case I set this behavior behind the setting SILKY_PYTHON_PROFILER_EXTENDED_FILE_NAME that by default is disabled.

If you think we can change the generated filename without worry we can simply apply this change always without the need to introduce the new settings.

@k4rl85 k4rl85 force-pushed the add_extended_profile_name branch 2 times, most recently from bd410d2 to 1be0b85 Compare January 3, 2023 20:36
@codecov
Copy link

codecov bot commented Jan 5, 2023

Codecov Report

Merging #638 (0dd5a0b) into master (415529c) will increase coverage by 0.08%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #638      +/-   ##
==========================================
+ Coverage   86.42%   86.51%   +0.08%     
==========================================
  Files          52       52              
  Lines        2078     2091      +13     
==========================================
+ Hits         1796     1809      +13     
  Misses        282      282              
Impacted Files Coverage Δ
silk/config.py 90.47% <ø> (ø)
silk/collector.py 90.60% <100.00%> (+0.89%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@albertyw
Copy link
Member

albertyw commented Jan 7, 2023

@k4rl85 can you try rebasing this pull request to get the tests to pass?

@k4rl85
Copy link
Contributor Author

k4rl85 commented Jan 11, 2023

@albertyw rebased the pr

"""Retrieve the profile file name to be proposed to the storage"""

if SilkyConfig().SILKY_PYTHON_PROFILER_EXTENDED_FILE_NAME:
request_path = self.request.path.replace('/', '_').lstrip('_')
Copy link
Member

Choose a reason for hiding this comment

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

I'm concerned that there are some other characters that could be in the request path that would cause issues. For example, if .. was in the path, it might lead to path traversal. A \ might also cause problems on windows systems.

I think it would be safer to strip all characters not in [a-z0-9_\-]+ (and maybe a few more) and also to limit the path to N (50?) characters.

Copy link
Contributor Author

@k4rl85 k4rl85 Jan 20, 2023

Choose a reason for hiding this comment

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

@albertyw I changed the logic to remove any not ASCII char and replace with _ any char not contained in [a-z0-9_].

I took as limit for path name length 50.

@k4rl85 k4rl85 force-pushed the add_extended_profile_name branch 2 times, most recently from 3299ce5 to 5e60656 Compare January 20, 2023 23:34
@albertyw albertyw merged commit a53d4ad into jazzband:master Jan 22, 2023
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.

None yet

2 participants