Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
43 lines (38 loc) · 1.31 KB

File metadata and controls

43 lines (38 loc) · 1.31 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- coding: utf-8 -*-
'''
The acl module handles client_acl operations
Additional information on client_acl can be
found by reading the salt documention:
http://docs.saltstack.com/en/latest/ref/clientacl.html
'''
# Import python libraries
from __future__ import absolute_import
import re
class ClientACL(object):
'''
Represents the client ACL and provides methods
to query the ACL for given operations
'''
def __init__(self, blacklist):
self.blacklist = blacklist
def user_is_blacklisted(self, user):
'''
Takes a username as a string and returns a boolean. True indicates that
the provided user has been blacklisted
'''
for blacklisted_user in self.blacklist.get('users', []):
if re.match(blacklisted_user, user):
return True
return False
def cmd_is_blacklisted(self, cmd):
for blacklisted_module in self.blacklist.get('modules', []):
# If this is a regular command, it is a single function
if isinstance(cmd, str):
funs_to_check = [cmd]
# If this is a compound function
else:
funs_to_check = cmd
for fun in funs_to_check:
if re.match(cmd, fun):
return True
return False
Morty Proxy This is a proxified and sanitized view of the page, visit original site.