Skip to content
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

1301 disable submit button #2989

Merged
merged 3 commits into from
Feb 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Changelog](https://keepachangelog.com/en/1.0.0/).
### Changed
### Removed
### Fixed
- Invalid configuration submit bug. #1301
- Notification spam bug. #2731

### Security
Expand Down
11 changes: 9 additions & 2 deletions monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class ConfigurePageComponent extends AuthComponent {
constructor(props) {
super(props);
this.currentSection = this.getSectionsOrder()[0];
this.validator = customizeValidator( {customFormats: formValidationFormats});

this.state = {
configuration: {},
Expand Down Expand Up @@ -397,7 +398,7 @@ class ConfigurePageComponent extends AuthComponent {
formProperties['className'] = 'config-form';
formProperties['liveValidate'] = true;
formProperties['formData'] = this.state.currentFormData;
formProperties['validator'] = customizeValidator( {customFormats: formValidationFormats});
formProperties['validator'] = this.validator;

applyUiSchemaManipulators(this.state.selectedSection,
formProperties['formData'],
Expand Down Expand Up @@ -440,6 +441,11 @@ class ConfigurePageComponent extends AuthComponent {
</Nav>)
};

isSubmitDisabled = () => {
let errors = this.validator.validateFormData(this.state.configuration, this.state.schema);
return errors.errors.length > 0
}

render() {
let displayedSchema = {};
if (Object.prototype.hasOwnProperty.call(this.state.schema, 'properties')) {
Expand All @@ -463,7 +469,8 @@ class ConfigurePageComponent extends AuthComponent {
{content}
<div className='text-center'>
<button type='submit' onClick={this.onSubmit} className='btn btn-success btn-lg'
style={{margin: '5px'}}>
style={{margin: '5px'}}
disabled={this.isSubmitDisabled()}>
Submit
</button>
<button type='button' onClick={this.resetConfig} className='btn btn-danger btn-lg'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const CREDENTIAL_COLLECTORS = {
'title': 'Credential Collectors',
'description': 'Click on a credential collector for more information.',
'type': 'string',
'type': 'object',
'pluginDefs': {
'MimikatzCollector':{'name': 'MimikatzCollector', 'options': {}},
'SSHCollector':{'name': 'SSHCollector', 'options': {}}
},
'properties':{
'type': 'string',
'name': {
'type': 'string',
'anyOf': [
{
'type': 'string',
Expand Down