Skip to content

Commit ef55d38

Browse files
committed
Merge branch 'master' into stable
2 parents 162c9cc + b2efc82 commit ef55d38

89 files changed

Lines changed: 7516 additions & 3397 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,6 @@ conf/conf.json
6767
logs
6868
.idea
6969
temp
70-
web
70+
/web
7171
web-src/node_modules
7272
web-src/package-lock.json

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ addons:
1212
env:
1313
global:
1414
- OWNER=${TRAVIS_REPO_SLUG%/*}
15-
- COMMIT=${TRAVIS_COMMIT::8}
1615
# GITHUB_TOKEN
1716
- secure: GtWCiMPNz3MDDTvXqaVsgZBvlxYRZuTY6sUEhWTL37zJZHgRLlxTCTD27hHZp2P4B6G6KGV/0iEvMYxqzo6jMrzcEnt7TlGetteqI18dhV1dIQGH6uy8Y/PktkK2g2FuJeGV3FRK4+a21v6zzSuUaFa26k97mPapa4LS83XXj7rc13ll23HhhtObVF/a1n3U0Xwe4FkdoxbKlecJUnNujESxFk4xQl4N1tFv15fldDlFq0XWs26eEp3LU/n7wkMzbg9WEqPvDeaYlvir9VpvcYWpVvf8Uz+wpvW1jnE2R6bK1TDv5BNzQwbf2JtN284yZ8I1nwZtOJkc1RUr5wUFxCD0p8tc30sAlKemI385v2t1ccoBYMwH8LHFIUoSXoolHZBsnZeADqpo3a0d8hVFWv4AcxC27Q6SfMCltl0+ogAoQ7wVfkRT++044p415Ar4raEqIkqTm64FaRNMS0v2y5mS2634PMSGMRnK+NBrWz1yFKxsiuPKypIWygtrJ4pyiL2yPBZupnCluEgqva3q6AmMDlNuSUmcTEnCRGB01U2if6/oSEgISH1VK2lsRSxuoG5dFFuezwv90YENh/7pw0/hgge7EOse6OzDsU3uNRWcTuXF7eEBhjM1wBHWHlaAwV9vfHMZX4sHWP4R4CZhPjVEPRz6HPEg1tFCs2EvkuI=
1817
# DOCKER_USER
@@ -23,14 +22,15 @@ before_install:
2322
- sudo apt-get -y install python3-pip python3-setuptools
2423
install:
2524
- sudo pip3 install -r requirements.txt
26-
- sudo pip3 install ldap3
25+
- sudo pip3 install ldap3 parameterized
26+
- sudo pip3 install requests --upgrade
2727
- sudo pip3 install pyasn1 --upgrade
2828
- cd web-src
2929
- npm install
3030
- cd ..
3131
before_script:
3232
- cd src
33-
- python3 -m unittest discover -s tests -p "*.py"
33+
- python3 -m unittest discover -s tests -p "*.py" -t .
3434
- cd ../web-src
3535
- npm run test
3636
- cd ..

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ Example of the user interface during script execution:
1818
- Different script parameter types
1919
- Alerts
2020
- Logging and auditing
21-
- Formatted output support (colors, styles, caret positioning)
21+
- Formatted output support (colors, styles, cursor positioning, clearing)
2222
- Download of script output files
2323
- Admin page (admin.html) with script execution logs
2424

25-
The features can be configured [per-script](https://github.com/bugy/script-server/wiki/Script-config) or for [the server](https://github.com/bugy/script-server/wiki/Server-config)
25+
The features can be configured [per-script](https://github.com/bugy/script-server/wiki/Script-config) or for [the server](https://github.com/bugy/script-server/wiki/Server-configuration)
2626

2727
## Requirements
2828
### Server-side
@@ -49,6 +49,10 @@ Internet connection is not needed. All the files are loaded from the server.
4949

5050
(For detailed steps on linux with virtualenv, please see [Installation guide](https://github.com/bugy/script-server/wiki/Installing-on-virtualenv-(linux)))
5151

52+
##### As a docker container
53+
Please find pre-built images here: https://hub.docker.com/r/bugy/script-server/tags
54+
For the usage please check [this ticket](https://github.com/bugy/script-server/issues/171#issuecomment-461620836)
55+
5256
### For development
5357
1. Clone/download the repository
5458
2. Run 'tools/init.py --dev --no-npm' script
@@ -68,7 +72,7 @@ By default, server will run on http://localhost:5000
6872
### Server config
6973
All the features listed above and some other minor features can be configured in *conf/conf.json* file.
7074
It is allowed not to create this file. In this case default values will be used.
71-
See [server config page](https://github.com/bugy/script-server/wiki/Server-config) for details
75+
See [server config page](https://github.com/bugy/script-server/wiki/Server-configuration) for details
7276

7377
### Admin panel
7478
Admin panel is accessible on admin.html page (e.g. http://localhost:5000/admin.html)
@@ -92,3 +96,15 @@ _Important!_ Command injection protection is fully supported for linux, but _onl
9296

9397
### XSS and CSRF
9498
At the moment script server _is_ vulnerable to these attacks.
99+
100+
## Contribution
101+
If you like the project and think you could help with making it better, there are many ways you can do it:
102+
- Create new issue for new feature proposal or a bug
103+
- Implement existing issues (there are quite some of them: frontend/backend, simple/complex, choose whatever you like)
104+
- Help with improving the documentation
105+
- Set up a demo server
106+
- Spread a word about the project to your collegues, friends, blogs or any other channels
107+
- Any other things you could imagine
108+
109+
Any contribution would be of great help and I will highly appreciate it!
110+
If you have any questions, please create a new issue, or concact me via buggygm@gmail.com

samples/configs/parameterized.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"name": "Very parameterized",
33
"script_path": "scripts/parameterized.sh",
44
"description": "This script does nothing except accepting a lot of parameters and printing them",
5-
"requires_terminal": false,
65
"allowed_users": [
76
"*"
87
],
@@ -95,11 +94,6 @@
9594
"description": "Boolean Two",
9695
"default": true
9796
},
98-
{
99-
"name": "Default Text from variable",
100-
"description": "Parameter Eight",
101-
"default": "$$USER"
102-
},
10397
{
10498
"name": "Constant Text",
10599
"description": "Constant value",
@@ -205,10 +199,9 @@
205199
"name": "Server file",
206200
"param": "--server_file",
207201
"type": "server_file",
208-
"file_dir": "/home/$$USER/Documents",
202+
"file_dir": "/var/log",
209203
"file_extensions": [
210-
"txt",
211-
"jpg"
204+
"log"
212205
],
213206
"secure": true
214207
},

samples/scripts/callback_test.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import os
2+
import sys
3+
4+
output_file = sys.argv[1]
5+
6+
with open(output_file, 'w') as f:
7+
for arg in sys.argv[2:]:
8+
f.write(arg + '\n')
9+
10+
f.write('\n\n')
11+
12+
fields = ['event_type', 'execution_id', 'pid', 'script_name', 'user', 'exit_code']
13+
14+
for field in fields:
15+
value = os.environ.get(field)
16+
17+
f.write(field + ': ' + str(value) + '\n')

samples/scripts/parameterized.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,15 @@ printf '%s\n' "${args[@]}"
3737
echo
3838

3939
if [ ! -z "$recurs_file" ]; then
40-
echo "recurs_file=$recurs_file"
41-
echo "md5="`md5sum "$recurs_file"`
40+
echo "recurs_file="`md5sum "$recurs_file"`
4241
fi
4342

4443
echo
4544

4645
if [ -z "$my_file" ]; then
4746
echo '--file_upload is empty'
4847
else
49-
echo '--file_upload content:'
50-
cat "$my_file"
48+
echo "--file_upload: "`md5sum "$my_file"`
5149
fi
5250

5351
sleep 5

src/alerts/alerts_service.py

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/alerts/destination_http.py

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/auth/authorization.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
from collections import defaultdict
22

3-
ANY_USER = 'ANY_USER'
3+
ANY_USER = '__ANY_USER'
44
ADMIN_GROUP = 'admin_users'
55
GROUP_PREFIX = '@'
66

77

88
class Authorizer:
99
def __init__(self, app_allowed_users, admin_users, groups_provider):
10-
if ANY_USER in app_allowed_users:
11-
self._app_auth_check = AnyUserAuthorizationCheck()
12-
else:
13-
self._app_auth_check = ListBasedAuthorizationCheck(app_allowed_users)
14-
10+
self._app_allowed_users = app_allowed_users
1511
self._admin_users = admin_users
12+
1613
self._groups_provider = groups_provider
1714

1815
def is_allowed_in_app(self, user_id):
19-
return self._app_auth_check.is_allowed(user_id)
16+
return self.is_allowed(user_id, self._app_allowed_users)
2017

2118
def is_admin(self, user_id):
22-
return user_id in self._admin_users
19+
return self.is_allowed(user_id, self._admin_users)
2320

2421
def is_allowed(self, user_id, allowed_users):
2522
if not allowed_users:
@@ -42,20 +39,6 @@ def is_allowed(self, user_id, allowed_users):
4239
return False
4340

4441

45-
class ListBasedAuthorizationCheck:
46-
def __init__(self, allowed_users) -> None:
47-
self.allowed_users = set(allowed_users)
48-
49-
def is_allowed(self, user_id):
50-
return user_id in self.allowed_users
51-
52-
53-
class AnyUserAuthorizationCheck:
54-
@staticmethod
55-
def is_allowed(user_id):
56-
return True
57-
58-
5942
class EmptyGroupProvider:
6043

6144
def get_groups(self, user):
@@ -124,6 +107,7 @@ def get_groups(self, user):
124107

125108
def create_group_provider(user_groups, authenticator, admin_users):
126109
if admin_users:
110+
admin_users = _exclude_unknown_groups_from_admin_users(admin_users, user_groups)
127111
if user_groups is None:
128112
user_groups = {ADMIN_GROUP: admin_users}
129113
elif ADMIN_GROUP not in user_groups:
@@ -139,3 +123,20 @@ def create_group_provider(user_groups, authenticator, admin_users):
139123
return preconfigured_groups_provider
140124

141125
return CombinedGroupProvider(preconfigured_groups_provider, authenticator)
126+
127+
128+
# in case groups will be loaded from ldap
129+
def _exclude_unknown_groups_from_admin_users(admin_users, known_groups):
130+
if not admin_users or not known_groups:
131+
return admin_users
132+
133+
result = []
134+
for user in admin_users:
135+
if user.startswith(GROUP_PREFIX):
136+
group = user[1:]
137+
if group not in known_groups.keys():
138+
continue
139+
140+
result.append(user)
141+
142+
return result

src/communications/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)