forked from p34709852/monkey
Trying to fix an edge where where the role is not set and there's and error while collecting machines.
This commit is contained in:
parent
f776765a27
commit
5018afb48b
|
@ -1,4 +1,6 @@
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
from botocore.exceptions import NoCredentialsError
|
||||||
from flask import request, jsonify, make_response
|
from flask import request, jsonify, make_response
|
||||||
import flask_restful
|
import flask_restful
|
||||||
|
|
||||||
|
@ -24,7 +26,12 @@ class RemoteRun(flask_restful.Resource):
|
||||||
is_aws = RemoteRunAwsService.is_running_on_aws()
|
is_aws = RemoteRunAwsService.is_running_on_aws()
|
||||||
resp = {'is_aws': is_aws}
|
resp = {'is_aws': is_aws}
|
||||||
if is_aws:
|
if is_aws:
|
||||||
resp['instances'] = AwsService.get_instances()
|
try:
|
||||||
|
resp['instances'] = AwsService.get_instances()
|
||||||
|
except NoCredentialsError as e:
|
||||||
|
# Probably, role hasn't been defined.
|
||||||
|
resp['error'] = e.message
|
||||||
|
return jsonify(resp)
|
||||||
return jsonify(resp)
|
return jsonify(resp)
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -8,6 +8,12 @@ import {Link} from 'react-router-dom';
|
||||||
import AuthComponent from '../AuthComponent';
|
import AuthComponent from '../AuthComponent';
|
||||||
import AwsRunTable from "../run-monkey/AwsRunTable";
|
import AwsRunTable from "../run-monkey/AwsRunTable";
|
||||||
|
|
||||||
|
const loading_css_override = css`
|
||||||
|
display: block;
|
||||||
|
margin-right: auto;
|
||||||
|
margin-left: auto;
|
||||||
|
`;
|
||||||
|
|
||||||
class RunMonkeyPageComponent extends AuthComponent {
|
class RunMonkeyPageComponent extends AuthComponent {
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
@ -28,7 +34,9 @@ class RunMonkeyPageComponent extends AuthComponent {
|
||||||
awsKeyId: '',
|
awsKeyId: '',
|
||||||
awsSecretKey: '',
|
awsSecretKey: '',
|
||||||
awsMachines: [],
|
awsMachines: [],
|
||||||
is_loading_aws: true
|
isLoadingAws: true,
|
||||||
|
isErrorWhileCollectingAwsMachines: false,
|
||||||
|
awsMachineCollectionErrorMsg: ''
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,8 +85,13 @@ class RunMonkeyPageComponent extends AuthComponent {
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(res =>{
|
.then(res =>{
|
||||||
let is_aws = res['is_aws'];
|
let is_aws = res['is_aws'];
|
||||||
|
let isErrorWhileCollectingAwsMachines = (res['error'] != null);
|
||||||
if (is_aws) {
|
if (is_aws) {
|
||||||
this.setState({isOnAws: true, awsMachines: res['instances'], isAwsAuth: res['auth'], is_loading_aws: false});
|
if (isErrorWhileCollectingAwsMachines) {
|
||||||
|
this.setState({isOnAws: true, isErrorWhileCollectingAwsMachines: true, awsMachineCollectionErrorMsg: res['error'], isAwsAuth: res['auth'], isLoadingAws: false});
|
||||||
|
} else {
|
||||||
|
this.setState({isOnAws: true, awsMachines: res['instances'], isAwsAuth: res['auth'], isLoadingAws: false});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -421,10 +434,11 @@ class RunMonkeyPageComponent extends AuthComponent {
|
||||||
</div>
|
</div>
|
||||||
</Collapse>
|
</Collapse>
|
||||||
{
|
{
|
||||||
this.state.is_loading_aws ?
|
this.state.isLoadingAws ?
|
||||||
<p style={{'marginBottom': '2em', 'align': 'center'}}>
|
<p style={{'marginBottom': '2em', 'align': 'center'}}>
|
||||||
<div className='sweet-loading'>
|
<div className='sweet-loading'>
|
||||||
<GridLoader
|
<GridLoader
|
||||||
|
css={loading_css_override}
|
||||||
sizeUnit={"px"}
|
sizeUnit={"px"}
|
||||||
size={30}
|
size={30}
|
||||||
color={'#ffcc00'}
|
color={'#ffcc00'}
|
||||||
|
@ -454,7 +468,16 @@ class RunMonkeyPageComponent extends AuthComponent {
|
||||||
}
|
}
|
||||||
<Collapse in={this.state.showAws}>
|
<Collapse in={this.state.showAws}>
|
||||||
{
|
{
|
||||||
this.renderAwsMachinesDiv()
|
this.state.isErrorWhileCollectingAwsMachines ?
|
||||||
|
<div style={{'marginTop': '1em'}}>
|
||||||
|
<p>
|
||||||
|
Error while collecting AWS machine data. Error message: {this.state.awsMachineCollectionErrorMsg}
|
||||||
|
|
||||||
|
Are you sure you've set the correct role? Not sure what this is? Not seeing your AWS EC2 instances? <a href="https://github.com/guardicore/monkey/wiki/Monkey-Island:-Running-the-monkey-on-AWS-EC2-instances">Read the documentation</a>!
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
:
|
||||||
|
this.renderAwsMachinesDiv()
|
||||||
}
|
}
|
||||||
|
|
||||||
</Collapse>
|
</Collapse>
|
||||||
|
|
Loading…
Reference in New Issue