-
Couldn't load subscription status.
- Fork 62
Implement docker outgoing firewall #254
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -142,7 +142,9 @@ def copyIn(self, vm, inputFiles): | |||||||||||||
| ) | ||||||||||||||
| return 0 | ||||||||||||||
|
|
||||||||||||||
| def runJob(self, vm, runTimeout, maxOutputFileSize, disableNetwork): | ||||||||||||||
| def runJob( | ||||||||||||||
| self, vm, runTimeout, maxOutputFileSize, disableNetwork, allowedOutgoingIPs | ||||||||||||||
| ): | ||||||||||||||
| """runJob - Run a docker container by doing the follows: | ||||||||||||||
| - mount directory corresponding to this job to /home/autolab | ||||||||||||||
| in the container | ||||||||||||||
|
|
@@ -163,6 +165,8 @@ def runJob(self, vm, runTimeout, maxOutputFileSize, disableNetwork): | |||||||||||||
| args = args + ["-m", f"{vm.memory}m"] | ||||||||||||||
| if disableNetwork: | ||||||||||||||
| args = args + ["--network", "none"] | ||||||||||||||
| if not disableNetwork and allowedOutgoingIPs: | ||||||||||||||
| args = args + ["--dns", "8.8.8.8", "--cap-add=NET_ADMIN"] | ||||||||||||||
| args = args + [vm.image] | ||||||||||||||
| args = args + ["sh", "-c"] | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -176,10 +180,17 @@ def runJob(self, vm, runTimeout, maxOutputFileSize, disableNetwork): | |||||||||||||
| ) | ||||||||||||||
| ) | ||||||||||||||
|
|
||||||||||||||
| iptablesCmd = "" | ||||||||||||||
| if not disableNetwork and allowedOutgoingIPs: | ||||||||||||||
| iptablesCmd += "iptables -A OUTPUT -d 8.8.8.8 -j ACCEPT; " | ||||||||||||||
| for IP in allowedOutgoingIPs: | ||||||||||||||
| iptablesCmd += f"iptables -A OUTPUT -d {IP} -j ACCEPT; " | ||||||||||||||
|
Comment on lines
+185
to
+187
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct the static string in the f-string. - iptablesCmd += "iptables -A OUTPUT -d 8.8.8.8 -j ACCEPT; "
+ iptablesCmd += f"iptables -A OUTPUT -d 8.8.8.8 -j ACCEPT; "Committable suggestion
Suggested change
|
||||||||||||||
| iptablesCmd += "iptables -A OUTPUT -j DROP;" | ||||||||||||||
|
|
||||||||||||||
| args = args + [ | ||||||||||||||
| 'cp -r mount/* autolab/; su autolab -c "%s"; \ | ||||||||||||||
| '%s cp -r mount/* autolab/; su autolab -c "%s"; \ | ||||||||||||||
| cp output/feedback mount/feedback' | ||||||||||||||
| % autodriverCmd | ||||||||||||||
| % (iptablesCmd, autodriverCmd) | ||||||||||||||
| ] | ||||||||||||||
|
|
||||||||||||||
| self.log.debug("Running job: %s" % str(args)) | ||||||||||||||
|
|
||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.