forked from p34709852/monkey
Merge pull request #1892 from guardicore/1888-fix-endpoint-urls
Fix endpoints urls
This commit is contained in:
commit
e9895a04f5
|
@ -26,6 +26,10 @@ Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Log messages to contain human-readable thread names. #1766
|
- Log messages to contain human-readable thread names. #1766
|
||||||
- The log file name to `infection-monkey-agent-<TIMESTAMP>-<RANDOM_STRING>.log`. #1761
|
- The log file name to `infection-monkey-agent-<TIMESTAMP>-<RANDOM_STRING>.log`. #1761
|
||||||
- "Logs" page renamed to "Telemetries". #1640
|
- "Logs" page renamed to "Telemetries". #1640
|
||||||
|
- The "/api/fileUpload" endpoint to "/api/file-upload". #1888
|
||||||
|
- The "/api/test/clear_caches" endpoint to "/api/test/clear-caches". #1888
|
||||||
|
- The "/api/netmap/nodeStates" endpoint to "/api/netmap/node-states". #1888
|
||||||
|
- All "/api/monkey_control" endpoints to "/api/monkey-control". #1888
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
- VSFTPD exploiter. #1533
|
- VSFTPD exploiter. #1533
|
||||||
|
|
|
@ -49,7 +49,7 @@ class MonkeyIslandClient(object):
|
||||||
@avoid_race_condition
|
@avoid_race_condition
|
||||||
def kill_all_monkeys(self):
|
def kill_all_monkeys(self):
|
||||||
response = self.requests.post_json(
|
response = self.requests.post_json(
|
||||||
"api/monkey_control/stop-all-agents", data={"kill_time": time.time()}
|
"api/monkey-control/stop-all-agents", data={"kill_time": time.time()}
|
||||||
)
|
)
|
||||||
if response.ok:
|
if response.ok:
|
||||||
LOGGER.info("Killing all monkeys after the test.")
|
LOGGER.info("Killing all monkeys after the test.")
|
||||||
|
@ -117,6 +117,6 @@ class MonkeyIslandClient(object):
|
||||||
:raises: If error (by error code), raises the error
|
:raises: If error (by error code), raises the error
|
||||||
:return: The response
|
:return: The response
|
||||||
"""
|
"""
|
||||||
response = self.requests.get("api/test/clear_caches")
|
response = self.requests.get("api/test/clear-caches")
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
return response
|
return response
|
||||||
|
|
|
@ -25,7 +25,7 @@ class ControlChannel(IControlChannel):
|
||||||
return True
|
return True
|
||||||
try:
|
try:
|
||||||
url = (
|
url = (
|
||||||
f"https://{self._control_channel_server}/api/monkey_control"
|
f"https://{self._control_channel_server}/api/monkey-control"
|
||||||
f"/needs-to-stop/{self._agent_id}"
|
f"/needs-to-stop/{self._agent_id}"
|
||||||
)
|
)
|
||||||
response = requests.get( # noqa: DUO123
|
response = requests.get( # noqa: DUO123
|
||||||
|
|
|
@ -137,7 +137,7 @@ def init_api_resources(api):
|
||||||
api.add_resource(NetMap, "/api/netmap")
|
api.add_resource(NetMap, "/api/netmap")
|
||||||
api.add_resource(Edge, "/api/netmap/edge")
|
api.add_resource(Edge, "/api/netmap/edge")
|
||||||
api.add_resource(Node, "/api/netmap/node")
|
api.add_resource(Node, "/api/netmap/node")
|
||||||
api.add_resource(NodeStates, "/api/netmap/nodeStates")
|
api.add_resource(NodeStates, "/api/netmap/node-states")
|
||||||
|
|
||||||
api.add_resource(SecurityReport, "/api/report/security")
|
api.add_resource(SecurityReport, "/api/report/security")
|
||||||
api.add_resource(ZeroTrustReport, "/api/report/zero-trust/<string:report_data>")
|
api.add_resource(ZeroTrustReport, "/api/report/zero-trust/<string:report_data>")
|
||||||
|
@ -153,19 +153,19 @@ def init_api_resources(api):
|
||||||
api.add_resource(PBAFileDownload, "/api/pba/download/<string:filename>")
|
api.add_resource(PBAFileDownload, "/api/pba/download/<string:filename>")
|
||||||
api.add_resource(
|
api.add_resource(
|
||||||
FileUpload,
|
FileUpload,
|
||||||
"/api/fileUpload/<string:file_type>",
|
"/api/file-upload/<string:file_type>",
|
||||||
"/api/fileUpload/<string:file_type>?load=<string:filename>",
|
"/api/file-upload/<string:file_type>?load=<string:filename>",
|
||||||
"/api/fileUpload/<string:file_type>?restore=<string:filename>",
|
"/api/file-upload/<string:file_type>?restore=<string:filename>",
|
||||||
)
|
)
|
||||||
api.add_resource(PropagationCredentials, "/api/propagation-credentials/<string:guid>")
|
api.add_resource(PropagationCredentials, "/api/propagation-credentials/<string:guid>")
|
||||||
api.add_resource(RemoteRun, "/api/remote-monkey")
|
api.add_resource(RemoteRun, "/api/remote-monkey")
|
||||||
api.add_resource(VersionUpdate, "/api/version-update")
|
api.add_resource(VersionUpdate, "/api/version-update")
|
||||||
api.add_resource(StopAgentCheck, "/api/monkey_control/needs-to-stop/<int:monkey_guid>")
|
api.add_resource(StopAgentCheck, "/api/monkey-control/needs-to-stop/<int:monkey_guid>")
|
||||||
api.add_resource(StopAllAgents, "/api/monkey_control/stop-all-agents")
|
api.add_resource(StopAllAgents, "/api/monkey-control/stop-all-agents")
|
||||||
|
|
||||||
# Resources used by black box tests
|
# Resources used by black box tests
|
||||||
api.add_resource(MonkeyBlackboxEndpoint, "/api/test/monkey")
|
api.add_resource(MonkeyBlackboxEndpoint, "/api/test/monkey")
|
||||||
api.add_resource(ClearCaches, "/api/test/clear_caches")
|
api.add_resource(ClearCaches, "/api/test/clear-caches")
|
||||||
api.add_resource(LogBlackboxEndpoint, "/api/test/log")
|
api.add_resource(LogBlackboxEndpoint, "/api/test/log")
|
||||||
api.add_resource(TelemetryBlackboxEndpoint, "/api/test/telemetry")
|
api.add_resource(TelemetryBlackboxEndpoint, "/api/test/telemetry")
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,8 @@ import HtmlFieldDescription from '../configuration-components/HtmlFieldDescripti
|
||||||
import CONFIGURATION_TABS_PER_MODE from '../configuration-components/ConfigurationTabs.js';
|
import CONFIGURATION_TABS_PER_MODE from '../configuration-components/ConfigurationTabs.js';
|
||||||
|
|
||||||
const CONFIG_URL = '/api/configuration/island';
|
const CONFIG_URL = '/api/configuration/island';
|
||||||
export const API_PBA_LINUX = '/api/fileUpload/PBAlinux';
|
export const API_PBA_LINUX = '/api/file-upload/PBAlinux';
|
||||||
export const API_PBA_WINDOWS = '/api/fileUpload/PBAwindows';
|
export const API_PBA_WINDOWS = '/api/file-upload/PBAwindows';
|
||||||
|
|
||||||
class ConfigurePageComponent extends AuthComponent {
|
class ConfigurePageComponent extends AuthComponent {
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ class MapPageComponent extends AuthComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
getNodeStateListFromServer = () => {
|
getNodeStateListFromServer = () => {
|
||||||
this.authFetch('/api/netmap/nodeStates')
|
this.authFetch('/api/netmap/node-states')
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(res => {
|
.then(res => {
|
||||||
this.setState({nodeStateList: res.node_states});
|
this.setState({nodeStateList: res.node_states});
|
||||||
|
@ -84,7 +84,7 @@ class MapPageComponent extends AuthComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
killAllMonkeys = () => {
|
killAllMonkeys = () => {
|
||||||
this.authFetch('/api/monkey_control/stop-all-agents',
|
this.authFetch('/api/monkey-control/stop-all-agents',
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {'Content-Type': 'application/json'},
|
headers: {'Content-Type': 'application/json'},
|
||||||
|
|
|
@ -171,7 +171,7 @@ class ReportPageComponent extends AuthComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
getNodeStateListFromServer = () => {
|
getNodeStateListFromServer = () => {
|
||||||
this.authFetch('/api/netmap/nodeStates')
|
this.authFetch('/api/netmap/node-states')
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(res => {
|
.then(res => {
|
||||||
this.setState({nodeStateList: res.node_states});
|
this.setState({nodeStateList: res.node_states});
|
||||||
|
|
|
@ -38,7 +38,7 @@ def mock_get_config_value(monkeypatch):
|
||||||
@pytest.mark.parametrize("pba_os", [LINUX_PBA_TYPE, WINDOWS_PBA_TYPE])
|
@pytest.mark.parametrize("pba_os", [LINUX_PBA_TYPE, WINDOWS_PBA_TYPE])
|
||||||
def test_pba_file_upload_post(flask_client, pba_os, monkeypatch, mock_set_config_value):
|
def test_pba_file_upload_post(flask_client, pba_os, monkeypatch, mock_set_config_value):
|
||||||
resp = flask_client.post(
|
resp = flask_client.post(
|
||||||
f"/api/fileUpload/{pba_os}",
|
f"/api/file-upload/{pba_os}",
|
||||||
data=TEST_FILE,
|
data=TEST_FILE,
|
||||||
content_type="multipart/form-data; " "boundary=---------------------------" "1",
|
content_type="multipart/form-data; " "boundary=---------------------------" "1",
|
||||||
follow_redirects=True,
|
follow_redirects=True,
|
||||||
|
@ -48,7 +48,7 @@ def test_pba_file_upload_post(flask_client, pba_os, monkeypatch, mock_set_config
|
||||||
|
|
||||||
def test_pba_file_upload_post__invalid(flask_client, monkeypatch, mock_set_config_value):
|
def test_pba_file_upload_post__invalid(flask_client, monkeypatch, mock_set_config_value):
|
||||||
resp = flask_client.post(
|
resp = flask_client.post(
|
||||||
"/api/fileUpload/bogus",
|
"/api/file-upload/bogus",
|
||||||
data=TEST_FILE,
|
data=TEST_FILE,
|
||||||
content_type="multipart/form-data; " "boundary=---------------------------" "1",
|
content_type="multipart/form-data; " "boundary=---------------------------" "1",
|
||||||
follow_redirects=True,
|
follow_redirects=True,
|
||||||
|
@ -66,7 +66,7 @@ def test_pba_file_upload_post__internal_server_error(
|
||||||
)
|
)
|
||||||
|
|
||||||
resp = flask_client.post(
|
resp = flask_client.post(
|
||||||
f"/api/fileUpload/{pba_os}",
|
f"/api/file-upload/{pba_os}",
|
||||||
data=TEST_FILE,
|
data=TEST_FILE,
|
||||||
content_type="multipart/form-data; boundary=---------------------------1",
|
content_type="multipart/form-data; boundary=---------------------------1",
|
||||||
follow_redirects=True,
|
follow_redirects=True,
|
||||||
|
@ -78,7 +78,7 @@ def test_pba_file_upload_post__internal_server_error(
|
||||||
def test_pba_file_upload_get__file_not_found(
|
def test_pba_file_upload_get__file_not_found(
|
||||||
flask_client, pba_os, monkeypatch, mock_get_config_value
|
flask_client, pba_os, monkeypatch, mock_get_config_value
|
||||||
):
|
):
|
||||||
resp = flask_client.get(f"/api/fileUpload/{pba_os}?load=bogus_mogus.py")
|
resp = flask_client.get(f"/api/file-upload/{pba_os}?load=bogus_mogus.py")
|
||||||
assert resp.status_code == 404
|
assert resp.status_code == 404
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,22 +87,22 @@ def test_pba_file_upload_endpoint(
|
||||||
flask_client, pba_os, monkeypatch, mock_get_config_value, mock_set_config_value
|
flask_client, pba_os, monkeypatch, mock_get_config_value, mock_set_config_value
|
||||||
):
|
):
|
||||||
resp_post = flask_client.post(
|
resp_post = flask_client.post(
|
||||||
f"/api/fileUpload/{pba_os}",
|
f"/api/file-upload/{pba_os}",
|
||||||
data=TEST_FILE,
|
data=TEST_FILE,
|
||||||
content_type="multipart/form-data; " "boundary=---------------------------" "1",
|
content_type="multipart/form-data; " "boundary=---------------------------" "1",
|
||||||
follow_redirects=True,
|
follow_redirects=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
resp_get = flask_client.get(f"/api/fileUpload/{pba_os}?load=test.py")
|
resp_get = flask_client.get(f"/api/file-upload/{pba_os}?load=test.py")
|
||||||
assert resp_get.status_code == 200
|
assert resp_get.status_code == 200
|
||||||
assert resp_get.data.decode() == "m0nk3y"
|
assert resp_get.data.decode() == "m0nk3y"
|
||||||
# Closing the response closes the file handle, else it can't be deleted
|
# Closing the response closes the file handle, else it can't be deleted
|
||||||
resp_get.close()
|
resp_get.close()
|
||||||
|
|
||||||
resp_delete = flask_client.delete(
|
resp_delete = flask_client.delete(
|
||||||
f"/api/fileUpload/{pba_os}", data="test.py", content_type="text/plain;"
|
f"/api/file-upload/{pba_os}", data="test.py", content_type="text/plain;"
|
||||||
)
|
)
|
||||||
resp_get_del = flask_client.get(f"/api/fileUpload/{pba_os}?load=test.py")
|
resp_get_del = flask_client.get(f"/api/file-upload/{pba_os}?load=test.py")
|
||||||
assert resp_post.status_code == 200
|
assert resp_post.status_code == 200
|
||||||
|
|
||||||
assert resp_delete.status_code == 200
|
assert resp_delete.status_code == 200
|
||||||
|
@ -114,14 +114,14 @@ def test_pba_file_upload_endpoint__invalid(
|
||||||
flask_client, monkeypatch, mock_set_config_value, mock_get_config_value
|
flask_client, monkeypatch, mock_set_config_value, mock_get_config_value
|
||||||
):
|
):
|
||||||
resp_post = flask_client.post(
|
resp_post = flask_client.post(
|
||||||
"/api/fileUpload/bogus",
|
"/api/file-upload/bogus",
|
||||||
data=TEST_FILE,
|
data=TEST_FILE,
|
||||||
content_type="multipart/form-data; " "boundary=---------------------------" "1",
|
content_type="multipart/form-data; " "boundary=---------------------------" "1",
|
||||||
follow_redirects=True,
|
follow_redirects=True,
|
||||||
)
|
)
|
||||||
resp_get = flask_client.get("/api/fileUpload/bogus?load=test.py")
|
resp_get = flask_client.get("/api/file-upload/bogus?load=test.py")
|
||||||
resp_delete = flask_client.delete(
|
resp_delete = flask_client.delete(
|
||||||
"/api/fileUpload/bogus", data="test.py", content_type="text/plain;"
|
"/api/file-upload/bogus", data="test.py", content_type="text/plain;"
|
||||||
)
|
)
|
||||||
assert resp_post.status_code == 422
|
assert resp_post.status_code == 422
|
||||||
assert resp_get.status_code == 422
|
assert resp_get.status_code == 422
|
||||||
|
|
Loading…
Reference in New Issue