-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Update app_svc.py #3198
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
base: master
Are you sure you want to change the base?
Update app_svc.py #3198
Conversation
Skip swap files created by nano while developing rules
|
Thoughts on swapping this out for only accepting .yml/.yaml files and nothing else? This would be more effective than playing whack-a-mole with other file extensions that may pop up due to other text editors |
|
@uruwhy , that's a great idea honestly.. this was just a quick fix while I was in the middle of another project.. The swp files here are binary and were capable of crashing the caldera instance. |
Update logic to exclude all non yml 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.
Pull Request Overview
This PR adds a file filter to prevent the application from processing non-YAML files when watching for ability file changes, specifically addressing errors caused by nano editor swap files during development.
- Adds a check to skip files that don't end with '.yml' extension
- Includes debug logging for skipped files
- Prevents UnicodeDecodeError exceptions from binary swap files
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| if not f.endswith('.yml'): | ||
| self.log.debug('[%s] Skipping non YML file %s' % (p.name, f)) |
Copilot
AI
Sep 29, 2025
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.
The file extension check is case-sensitive and only matches '.yml'. YAML files can also have '.yaml' extension, which would be skipped by this filter. Consider using a case-insensitive check that accepts both '.yml' and '.yaml' extensions.
| if not f.endswith('.yml'): | |
| self.log.debug('[%s] Skipping non YML file %s' % (p.name, f)) | |
| if not f.lower().endswith(('.yml', '.yaml')): | |
| self.log.debug('[%s] Skipping non YAML file %s' % (p.name, f)) |
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.
thoughts on this suggestion? I'd keep the tuple part but discard the lower() since the file extensions on linux will be case-sensitive
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.
@uruwhy that's fair, my usually background is on windows hosts, so I make everything case insensitive.
Big thing I was shooting for was avoiding crashing my instance by reading binary temp files.
|



Skip swap files created by nano while developing rules.
Description
Small fix for app_svc to avoid errors from swp files while locally editing with nano while caldera is running.
Type of change
How Has This Been Tested?
Tested locally, after making the change nano editing no longer throws errors (like the following)
Checklist:
(none needed)