Skip to content

Commit 7358c09

Browse files
committed
a bit more secure
1 parent 756f75c commit 7358c09

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

‎v4-cokapi/Dockerfile‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# docker build -t="pgbovine/cokapi:v1" .
33
#
44
# to test:
5-
# docker run -t -i --rm pgbovine/cokapi:v1 bash
5+
# docker run -t -i --rm --user=netuser --net=none --cap-drop all pgbovine/cokapi:v1 bash
66
#
77
# remember --rm or else stale old containers will be left around!
88
# use "docker ps -a" to see all containers
@@ -41,3 +41,5 @@ ADD backends/python /tmp/python
4141

4242
COPY backends/java/run-java-backend.sh /tmp/
4343
RUN chmod a+x /tmp/run-java-backend.sh
44+
45+
RUN useradd netuser

‎v4-cokapi/cokapi.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2929
// This is a nodejs server based on express that serves the v4-cokapi/ app
3030
// To test locally, run 'make' and load http://localhost:3000/
3131

32-
var IS_DEBUG = true;
32+
var IS_DEBUG = false;
3333

3434
var PRODUCTION_PORT = 3000;
3535
var DEBUG_PORT = 5001;
@@ -116,7 +116,7 @@ function exec_js_handler(useJSONP /* use bind first */, req, res) {
116116
if (USE_DOCKER_SANDBOX) {
117117
// this needs to match the docker setup in Dockerfile
118118
exeFile = '/usr/bin/docker'; // absolute path to docker executable
119-
args.push('run', '--rm', 'pgbovine/cokapi:v1',
119+
args.push('run', '--rm', '--user=netuser', '--net=none', '--cap-drop', 'all', 'pgbovine/cokapi:v1',
120120
'node',
121121
'--expose-debug-as=Debug',
122122
'/tmp/javascript/jslogger.js');
@@ -171,7 +171,7 @@ function exec_java_handler(useJSONP /* use bind first */, req, res) {
171171
if (USE_DOCKER_SANDBOX) {
172172
// this needs to match the docker setup in Dockerfile
173173
exeFile = '/usr/bin/docker'; // absolute path to docker executable
174-
args.push('run', '--rm', 'pgbovine/cokapi:v1',
174+
args.push('run', '--rm', '--user=netuser', '--net=none', '--cap-drop', 'all', 'pgbovine/cokapi:v1',
175175
'/tmp/run-java-backend.sh',
176176
inputObjJSON);
177177
} else {
@@ -203,7 +203,7 @@ function executePython(pyVer, req, res) {
203203
if (USE_DOCKER_SANDBOX) {
204204
// this needs to match the docker setup in Dockerfile
205205
exeFile = '/usr/bin/docker'; // absolute path to docker executable
206-
args.push('run', '--rm', 'pgbovine/cokapi:v1',
206+
args.push('run', '--rm', '--user=netuser', '--net=none', '--cap-drop', 'all', 'pgbovine/cokapi:v1',
207207
(pyVer == 'py2' ? 'python' : 'python3'),
208208
'/tmp/python/generate_json_trace.py');
209209
} else {

0 commit comments

Comments
 (0)