Skip to content

Commit b2c7a78

Browse files
committed
Merge branch 'master' into stable
2 parents 0fe5216 + a1afd15 commit b2c7a78

138 files changed

Lines changed: 9600 additions & 2813 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.

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ For system administrators it's a possibility to share their scripts with users,
88

99
No script modifications are needed - you add a configuration for each script to the script-server and it takes care of proper UI, validation, execution, etc.
1010

11-
Example of the user interface during script execution:
12-
![Example of user interface](https://cloud.githubusercontent.com/assets/1275813/26519407/f0318706-42c0-11e7-8328-34ded505839c.png)
11+
12+
[DEMO server](https://script-server.net)
1313

1414
## Features
1515
- Interactive output/input web console
@@ -27,7 +27,7 @@ The features can be configured [per-script](https://github.com/bugy/script-serve
2727
## Requirements
2828
### Server-side
2929
Python 3.4 or higher with the following modules:
30-
* Tornado 4/5
30+
* Tornado 4 / 5 / 6
3131
* typing *(for python 3.4 only)*
3232

3333
Some features can require additional modules. Such requirements are specified in a corresponding feature description.
@@ -108,3 +108,6 @@ If you like the project and think you could help with making it better, there ar
108108

109109
Any contribution would be of great help and I will highly appreciate it!
110110
If you have any questions, please create a new issue, or concact me via buggygm@gmail.com
111+
112+
## Special thanks
113+
![JetBrains logo](https://github.com/JetBrains/logos/blob/master/web/jetbrains/jetbrains.svg)

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
typing
2-
tornado<6
2+
tornado>=4

samples/configs/destroy_world.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2+
"name": "destroy_world",
23
"script_path": "./samples/scripts/destroy_world.py",
34
"description": "This is a very dangerous script, please be careful when running. Don't forget your protective helmet.",
4-
"requires_terminal": true
5+
"requires_terminal": false
56
}

samples/configs/mult_words.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "Multiple words",
33
"script_path": "'mult words.py' 1 'word 2' '' 'word4'",
4-
"description": "Executes a complex command specified as a scripts path and prints all incoming parameters",
54
"working_directory": "./samples/scripts/",
5+
"description": "Executes a complex command specified as a scripts path and prints all incoming parameters",
66
"parameters": [
77
{
88
"name": "Param1",
@@ -15,4 +15,4 @@
1515
"default": "a single parameter"
1616
}
1717
]
18-
}
18+
}

samples/configs/parameterized.json

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "Very parameterized",
33
"script_path": "scripts/parameterized.sh",
4+
"working_directory": "./samples",
45
"description": "This script does nothing except accepting a lot of parameters and printing them",
56
"allowed_users": [
67
"*"
78
],
89
"include": "${Simple Text}.json",
9-
"working_directory": "./samples",
1010
"parameters": [
1111
{
1212
"name": "Simple Int",
@@ -21,14 +21,15 @@
2121
},
2222
{
2323
"name": "Simple Text",
24+
"required": true,
2425
"param": "--simple_text",
2526
"description": "Parameter Four"
2627
},
2728
{
2829
"name": "Simple List",
2930
"param": "--simple_list",
30-
"description": "Parameter Five",
3131
"type": "list",
32+
"description": "Parameter Five",
3233
"values": [
3334
"val1",
3435
"val3",
@@ -37,15 +38,15 @@
3738
},
3839
{
3940
"name": "File upload",
40-
"description": "File upload testing",
41+
"param": "--file_upload",
4142
"type": "file_upload",
42-
"param": "--file_upload"
43+
"description": "File upload testing"
4344
},
4445
{
4546
"name": "Multiple selection",
46-
"description": "Multiselect list",
47-
"type": "multiselect",
4847
"param": "--multiselect",
48+
"type": "multiselect",
49+
"description": "Multiselect list",
4950
"values": [
5051
"Black cat",
5152
"Brown dog",
@@ -55,74 +56,75 @@
5556
},
5657
{
5758
"name": "Required Text",
59+
"required": true,
5860
"param": "--required_text",
5961
"description": "Parameter One",
60-
"required": true
62+
"env_var": "Req_Text"
6163
},
6264
{
6365
"name": "Required List",
66+
"required": true,
6467
"param": "--required_list",
65-
"description": "List with required value",
6668
"type": "list",
67-
"required": true,
69+
"description": "List with required value",
6870
"values": [
6971
"v1",
7072
"v2"
7173
]
7274
},
7375
{
7476
"name": "Constrained Int",
77+
"required": "true",
7578
"param": "--constrained_int",
76-
"description": "Parameter Three",
7779
"type": "int",
78-
"required": "true",
7980
"default": "5",
81+
"description": "Parameter Three",
8082
"min": "-1",
8183
"max": "123"
8284
},
8385
{
8486
"name": "Default Text",
85-
"param": "--def_text",
86-
"description": "Text with default value and required",
8787
"required": true,
88-
"default": "some_text"
88+
"param": "--def_text",
89+
"default": "some_text",
90+
"description": "Text with default value and required"
8991
},
9092
{
9193
"name": "Default Boolean",
9294
"param": "--def_bool",
9395
"no_value": true,
94-
"description": "Boolean Two",
95-
"default": true
96+
"default": true,
97+
"description": "Boolean Two"
9698
},
9799
{
98100
"name": "Constant Text",
99-
"description": "Constant value",
100101
"param": "--const_text",
102+
"default": "constOne",
101103
"constant": true,
102-
"default": "constOne"
104+
"description": "Constant value"
103105
},
104106
{
105107
"name": "Command-based list",
106108
"param": "--var_file",
107-
"description": "List parameter 2",
108109
"type": "list",
110+
"description": "List parameter 2",
109111
"values": {
110112
"script": "ls /var"
111113
}
112114
},
113115
{
114116
"name": "Secure Int",
117+
"type": "int",
115118
"description": "Parameter Nine",
116-
"secure": true,
117-
"type": "int"
119+
"secure": true
118120
},
119121
{
120122
"name": "Secure List",
121-
"description": "Parameter Ten",
122-
"secure": true,
123+
"param": "--secure_list",
123124
"type": "list",
124125
"default": "qwerty",
125-
"param": "--secure_list",
126+
"description": "Parameter Ten",
127+
"secure": true,
126128
"values": [
127129
"qwerty",
128130
"12345678",
@@ -131,9 +133,9 @@
131133
},
132134
{
133135
"name": "Very long list",
134-
"description": "List with very long values",
135-
"type": "list",
136136
"param": "--very_long_list",
137+
"type": "list",
138+
"description": "List with very long values",
137139
"values": [
138140
"some quite long line",
139141
"short",
@@ -145,25 +147,25 @@
145147
},
146148
{
147149
"name": "Multiselect as secure arguments",
148-
"description": "Multiselect list as multiple arguments",
149-
"type": "multiselect",
150150
"required": true,
151-
"multiple_arguments": true,
152-
"secure": true,
151+
"type": "multiselect",
153152
"default": [
154153
"multi1",
155154
"multi 3"
156155
],
156+
"description": "Multiselect list as multiple arguments",
157+
"secure": true,
157158
"values": [
158159
"multi1",
159160
"multi2",
160161
"multi 3"
161-
]
162+
],
163+
"multiple_arguments": true
162164
},
163165
{
164166
"name": "Dependant list",
165-
"description": "A list with values depending on other parameters",
166167
"type": "list",
168+
"description": "A list with values depending on other parameters",
167169
"values": {
168170
"script": "ls /var/${Command-based list}/${Required Text}"
169171
}
@@ -175,9 +177,9 @@
175177
},
176178
{
177179
"name": "Audit name",
178-
"constant": true,
179180
"param": "--audit_name",
180-
"default": "${auth.audit_name}"
181+
"default": "${auth.audit_name}",
182+
"constant": true
181183
},
182184
{
183185
"name": "Any IP",
@@ -199,28 +201,28 @@
199201
"name": "Server file",
200202
"param": "--server_file",
201203
"type": "server_file",
204+
"secure": true,
202205
"file_dir": "/var/log",
203206
"file_extensions": [
204207
"log"
205-
],
206-
"secure": true
208+
]
207209
},
208210
{
209211
"name": "Recursive file",
210212
"param": "--recurs_file",
211213
"type": "server_file",
214+
"default": [
215+
"samples",
216+
"configs",
217+
"parameterized.json"
218+
],
219+
"secure": true,
212220
"file_dir": "..",
213221
"file_recursive": true,
214222
"file_extensions": [
215223
"json",
216224
".log",
217225
"TXT"
218-
],
219-
"secure": true,
220-
"default": [
221-
"samples",
222-
"configs",
223-
"parameterized.json"
224226
]
225227
}
226228
]

samples/configs/write_file.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
"@admin_users",
88
"127.0.0.1"
99
],
10+
"output_files": [
11+
"##any_path#",
12+
"~/${filename}",
13+
{
14+
"type": "inline-image",
15+
"path": "##any_path.png#"
16+
}
17+
],
1018
"parameters": [
1119
{
1220
"name": "text",
@@ -17,8 +25,8 @@
1725
"name": "repeats",
1826
"param": "-r",
1927
"type": "int",
20-
"min": 1,
21-
"description": "How many times the text should be written to the file"
28+
"description": "How many times the text should be written to the file",
29+
"min": 1
2230
},
2331
{
2432
"name": "clear file",
@@ -31,9 +39,5 @@
3139
"param": "-f",
3240
"description": "Custom filename"
3341
}
34-
],
35-
"output_files": [
36-
"##any_path#",
37-
"~/${filename}"
3842
]
3943
}

samples/scripts/parameterized.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,9 @@ else
4848
echo "--file_upload: "`md5sum "$my_file"`
4949
fi
5050

51+
echo
52+
echo 'Environment variables:'
53+
echo 'Req_Text='"$Req_Text"
54+
printenv | grep -P '^PARAM_'
55+
5156
sleep 5

src/auth/auth_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def authenticate(self, request_handler):
1313
def get_client_visible_config(self):
1414
return self._client_visible_config
1515

16-
def get_groups(self, user):
16+
def get_groups(self, user, known_groups=None):
1717
return []
1818

1919

src/auth/auth_ldap.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from string import Template
55

66
from ldap3 import Connection, SIMPLE
7+
from ldap3.core.exceptions import LDAPAttributeError
78

89
from auth import auth_base
910
from model import model_helper
@@ -62,6 +63,13 @@ def _load_multiple_entries_values(dn, search_filter, attribute_name, connection)
6263
return result
6364

6465

66+
def get_entry_dn(entry):
67+
try:
68+
return entry.entry_dn
69+
except LDAPAttributeError:
70+
return entry._dn
71+
72+
6573
class LdapAuthenticator(auth_base.Authenticator):
6674
def __init__(self, params_dict, temp_folder):
6775
super().__init__()
@@ -158,7 +166,7 @@ def _get_groups(self, user):
158166
self._user_groups[user] = groups
159167
return groups
160168

161-
def get_groups(self, user):
169+
def get_groups(self, user, known_groups=None):
162170
return self._get_groups(user)
163171

164172
def _fetch_user_groups(self, user_dn, user_uid, connection):
@@ -203,7 +211,7 @@ def _get_user_ids(self, full_username, connection):
203211
return full_username, None
204212

205213
entry = entries[0]
206-
return entry.entry_dn, entry.uid.value
214+
return get_entry_dn(entry), entry.uid.value
207215

208216
def _load_groups(self, groups_file):
209217
if not os.path.exists(groups_file):

0 commit comments

Comments
 (0)