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

Add rule_type=rsync; Add pcre for file definitions #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

thinksilicon
Copy link

Basic configuration of rsync via the yaml configuration. This should prevent anything from running without the --server flag.
Also added the option to define pcre's for file names, so you can define wildcards, etc.

Basic configuration of rsync via the yaml configuration. This should prevent anything from running without the --server flag.
Also added the option to define pcre's for file names, so you can define wildcards, etc.
@daethnir
Copy link
Owner

You have encouraged me to get off my duff.

I've got the bulk of rsync support in a branch I've failed to push up. Give me a week to finish up the unit tests and I'd love to get your eyes on it.

@thinksilicon
Copy link
Author

Hey, that would be great. My code was really just to get some basic functionality, but it doesn't do any extensive argument parsing.

If you could however add my portion of the preg_match for file-names as well, that would be helpful.

Base automatically changed from master to main February 16, 2021 02:32
@daethnir
Copy link
Owner

Can you check out the new rsync functionality - should meet your needs.

@@ -386,12 +386,93 @@ def find_match_scp(self, rule): # pylint: disable-msg=R0911,R0912
files = rule.get('files')
if not isinstance(files, list):
files = [files]
if filepath not in files:
if rule.get('pcre_match'):
Copy link
Owner

Choose a reason for hiding this comment

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

Can we be more clear that this is a pcre against the filename.

Rather than overloading 'files' lets add a new one, path_pcre (this will mirror the path_startswith that came in latest version)

files:
  - foo.txt
  - bar.txt 
paths_pcre: 
  - foo.*txt

Alternatively, if you don't actually need pcre and glob works then use path_glob - there is also now glob support in authprogs.py, which is used by rsync.

self.log(
'scp denied - file "{}" - not in approved '
'list {}\n'.format(filepath, files)
'regex {}\n'.format( filepath, files )
Copy link
Owner

Choose a reason for hiding this comment

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

Additional needs:

  • unit tests
  • update to doc/authprogs.md (man page)

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.

2 participants