forked from p15670423/monkey
Merge pull request #983 from shreyamalviya/bugfix-run-monkey-manual-ignores-configured-ip
Show only configured IPs for Run Monkey -> Manual page
This commit is contained in:
commit
b652e0d851
|
@ -0,0 +1,34 @@
|
|||
import pytest
|
||||
|
||||
import monkey_island.cc.services.config
|
||||
from monkey_island.cc.environment import Environment
|
||||
from monkey_island.cc.services.config import ConfigService
|
||||
|
||||
IPS = ["0.0.0.0", "9.9.9.9"]
|
||||
PORT = 9999
|
||||
|
||||
# If tests fail because config path is changed, sync with
|
||||
# monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage/RunOptions.js
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def config(monkeypatch):
|
||||
monkeypatch.setattr("monkey_island.cc.services.config.local_ip_addresses",
|
||||
lambda: IPS)
|
||||
monkeypatch.setattr(Environment, "_ISLAND_PORT", PORT)
|
||||
config = ConfigService.get_default_config(True)
|
||||
return config
|
||||
|
||||
|
||||
def test_set_server_ips_in_config_command_servers(config):
|
||||
ConfigService.set_server_ips_in_config(config)
|
||||
expected_config_command_servers = [f"{ip}:{PORT}" for ip in IPS]
|
||||
assert config["internal"]["island_server"]["command_servers"] ==\
|
||||
expected_config_command_servers
|
||||
|
||||
|
||||
def test_set_server_ips_in_config_current_server(config):
|
||||
ConfigService.set_server_ips_in_config(config)
|
||||
expected_config_current_server = f"{IPS[0]}:{PORT}"
|
||||
assert config["internal"]["island_server"]["current_server"] ==\
|
||||
expected_config_current_server
|
|
@ -10,6 +10,8 @@ import RunOnIslandButton from './RunOnIslandButton';
|
|||
import AWSRunButton from './RunOnAWS/AWSRunButton';
|
||||
import CloudOptions from './scoutsuite-setup/CloudOptions';
|
||||
|
||||
const CONFIG_URL = '/api/configuration/island';
|
||||
|
||||
function RunOptions(props) {
|
||||
|
||||
const [currentContent, setCurrentContent] = useState(loadingContents());
|
||||
|
@ -20,10 +22,14 @@ function RunOptions(props) {
|
|||
|
||||
useEffect(() => {
|
||||
if (initialized === false) {
|
||||
authComponent.authFetch('/api')
|
||||
authComponent.authFetch(CONFIG_URL)
|
||||
.then(res => res.json())
|
||||
.then(res => {
|
||||
setIps([res['ip_addresses']][0]);
|
||||
let commandServers = res.configuration.internal.island_server.command_servers;
|
||||
let ipAddresses = commandServers.map(ip => {
|
||||
return ip.split(":", 1);
|
||||
});
|
||||
setIps(ipAddresses);
|
||||
setInitialized(true);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue