forked from p34709852/monkey
Added validation to important tabs (not-internal)
This commit is contained in:
parent
db6552a136
commit
5449084394
|
@ -0,0 +1,3 @@
|
||||||
|
# Defined in UI on ValidationFormats.js
|
||||||
|
IP_RANGE = "ip-range"
|
||||||
|
IP = "ip"
|
|
@ -1,3 +1,4 @@
|
||||||
|
from common.data.validation_formats import IP, IP_RANGE
|
||||||
from monkey_island.cc.services.utils.typographic_symbols import WARNING_SIGN
|
from monkey_island.cc.services.utils.typographic_symbols import WARNING_SIGN
|
||||||
|
|
||||||
BASIC_NETWORK = {
|
BASIC_NETWORK = {
|
||||||
|
@ -13,7 +14,8 @@ BASIC_NETWORK = {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"uniqueItems": True,
|
"uniqueItems": True,
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string"
|
"type": "string",
|
||||||
|
"format": IP,
|
||||||
},
|
},
|
||||||
"default": [
|
"default": [
|
||||||
],
|
],
|
||||||
|
@ -28,6 +30,7 @@ BASIC_NETWORK = {
|
||||||
"depth": {
|
"depth": {
|
||||||
"title": "Distance from island",
|
"title": "Distance from island",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
|
"minimum": 1,
|
||||||
"default": 2,
|
"default": 2,
|
||||||
"description":
|
"description":
|
||||||
"Amount of hops allowed for the monkey to spread from the island. "
|
"Amount of hops allowed for the monkey to spread from the island. "
|
||||||
|
@ -39,7 +42,8 @@ BASIC_NETWORK = {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"uniqueItems": True,
|
"uniqueItems": True,
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string"
|
"type": "string",
|
||||||
|
"format": IP_RANGE
|
||||||
},
|
},
|
||||||
"default": [
|
"default": [
|
||||||
],
|
],
|
||||||
|
@ -59,7 +63,8 @@ BASIC_NETWORK = {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"uniqueItems": True,
|
"uniqueItems": True,
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string"
|
"type": "string",
|
||||||
|
"format": IP_RANGE
|
||||||
},
|
},
|
||||||
"default": [
|
"default": [
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
from monkey_island.cc.services.utils.typographic_symbols import WARNING_SIGN
|
|
||||||
from common.data.system_info_collectors_names import (AWS_COLLECTOR,
|
from common.data.system_info_collectors_names import (AWS_COLLECTOR,
|
||||||
ENVIRONMENT_COLLECTOR,
|
ENVIRONMENT_COLLECTOR,
|
||||||
HOSTNAME_COLLECTOR,
|
HOSTNAME_COLLECTOR,
|
||||||
|
@ -101,6 +100,7 @@ MONKEY = {
|
||||||
"title": "Max iterations",
|
"title": "Max iterations",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"default": 1,
|
"default": 1,
|
||||||
|
"minimum": 1,
|
||||||
"description": "Determines how many iterations of the monkey's full lifecycle should occur "
|
"description": "Determines how many iterations of the monkey's full lifecycle should occur "
|
||||||
"(how many times to do the scan)"
|
"(how many times to do the scan)"
|
||||||
},
|
},
|
||||||
|
@ -108,6 +108,7 @@ MONKEY = {
|
||||||
"title": "Wait time between iterations",
|
"title": "Wait time between iterations",
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"default": 100,
|
"default": 100,
|
||||||
|
"minimum": 0,
|
||||||
"description":
|
"description":
|
||||||
"Determines for how long (in seconds) should the monkey wait before starting another scan"
|
"Determines for how long (in seconds) should the monkey wait before starting another scan"
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,7 +13,14 @@ export default function UiSchema(props) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
basic_network: {},
|
basic_network: {
|
||||||
|
'ui:order': ['scope', 'network_analysis'],
|
||||||
|
scope: {
|
||||||
|
subnet_scan_list:{
|
||||||
|
format: 'ip-list',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
monkey: {
|
monkey: {
|
||||||
post_breach: {
|
post_breach: {
|
||||||
post_breach_actions: {
|
post_breach_actions: {
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
const ipRegex = '((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'
|
||||||
|
const cidrNotationRegex = '([0-9]|1[0-9]|2[0-9]|3[0-2])'
|
||||||
|
|
||||||
|
export const formValidationFormats = {
|
||||||
|
'ip-range': buildIpRangeRegex(),
|
||||||
|
'ip': buildIpRegex(),
|
||||||
|
};
|
||||||
|
|
||||||
|
function buildIpRangeRegex(){
|
||||||
|
return new RegExp([
|
||||||
|
'^'+ipRegex+'$|', // Single IP
|
||||||
|
'^'+ipRegex+'-'+ipRegex+'$|', // IP range IP-IP
|
||||||
|
'^'+ipRegex+'/'+cidrNotationRegex+'$' // IP range with cidr notation: IP/cidr
|
||||||
|
].join(''))
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildIpRegex(){
|
||||||
|
return new RegExp('^'+ipRegex+'$')
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
|
||||||
import {faInfoCircle} from '@fortawesome/free-solid-svg-icons/faInfoCircle';
|
import {faInfoCircle} from '@fortawesome/free-solid-svg-icons/faInfoCircle';
|
||||||
import {faCheck} from '@fortawesome/free-solid-svg-icons/faCheck';
|
import {faCheck} from '@fortawesome/free-solid-svg-icons/faCheck';
|
||||||
import {faExclamationCircle} from '@fortawesome/free-solid-svg-icons/faExclamationCircle';
|
import {faExclamationCircle} from '@fortawesome/free-solid-svg-icons/faExclamationCircle';
|
||||||
|
import {formValidationFormats} from "../configuration-components/ValidationFormats";
|
||||||
|
|
||||||
const ATTACK_URL = '/api/attack';
|
const ATTACK_URL = '/api/attack';
|
||||||
const CONFIG_URL = '/api/configuration/island';
|
const CONFIG_URL = '/api/configuration/island';
|
||||||
|
@ -342,8 +343,9 @@ class ConfigurePageComponent extends AuthComponent {
|
||||||
})}
|
})}
|
||||||
formData={this.state.configuration[this.state.selectedSection]}
|
formData={this.state.configuration[this.state.selectedSection]}
|
||||||
onChange={this.onChange}
|
onChange={this.onChange}
|
||||||
noValidate={true}
|
customFormats={formValidationFormats}
|
||||||
className={'config-form'}>
|
className={'config-form'}
|
||||||
|
liveValidate>
|
||||||
<button type='submit' className={'hidden'}>Submit</button>
|
<button type='submit' className={'hidden'}>Submit</button>
|
||||||
</Form>
|
</Form>
|
||||||
</div>)
|
</div>)
|
||||||
|
|
|
@ -31,6 +31,10 @@
|
||||||
margin-left: 2em;
|
margin-left: 2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.config-form div.card.errors {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.config-template-no-header > p {
|
.config-template-no-header > p {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue