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

Splunk2HDF Updates #2675

Merged
merged 61 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
948e984
Don't assume descriptions is defined
camdenmoors Feb 28, 2022
92047c4
Add Splunk Logging
camdenmoors Feb 28, 2022
6a6b689
Add insecure mode
camdenmoors Feb 28, 2022
1029179
Merge branch 'master' into splunkUpdates
camdenmoors Feb 28, 2022
b2d9632
Upload multiple items to collector at once
camdenmoors Feb 28, 2022
bed0792
Remove set index value, add hint for hostname field, fix profile subt…
camdenmoors Feb 28, 2022
ea4f2a0
Revert "Upload multiple items to collector at once"
camdenmoors Feb 28, 2022
6a05eba
Add hint for admin
camdenmoors Feb 28, 2022
0994aec
Remove spath.meta
camdenmoors Feb 28, 2022
985e647
Use index="*"
camdenmoors Feb 28, 2022
5efb07e
Set empty array for Profile.controls
camdenmoors Feb 28, 2022
f469d10
Log getExecution result
camdenmoors Feb 28, 2022
1e9cd54
Use replaceKeyValue descriptions
camdenmoors Feb 28, 2022
840b69f
Allow undefined return values, remove FileList log, increase timeout
camdenmoors Mar 1, 2022
a5f98bf
Add better error handling to SplunkReader, remove admin hint
camdenmoors Mar 1, 2022
8da1f4c
Post test data to webhook
camdenmoors Mar 1, 2022
bcb7ae5
Update test data, remove webhook
camdenmoors Mar 1, 2022
1d42282
Ignore LGTM issue and comment on insecure mode
camdenmoors Mar 1, 2022
40c61ae
Allow passing custom search to SplunkReader
camdenmoors Mar 1, 2022
782146c
Use notify for success message
camdenmoors Mar 1, 2022
3506a13
Revert "Allow passing custom search to SplunkReader"
camdenmoors Mar 1, 2022
c743de6
Add title
camdenmoors Mar 2, 2022
ae94be8
Merge branch 'splunkUpdates' of https://github.com/mitre/heimdall2 in…
camdenmoors Mar 2, 2022
09a6422
Clean up SplunkReader usability, add splunk-sdk to hdf-converters, de…
camdenmoors Mar 2, 2022
a304623
Switch to splunk-sdk for hdf2splunk, upload multiple events at once
camdenmoors Mar 3, 2022
d183b12
Switch to @mitre/splunk-sdk-no-env
camdenmoors Mar 3, 2022
f667092
Follow Sonarqube suggestions, update mapper tests
camdenmoors Mar 4, 2022
a16edd9
Update splunk_reverse_mapper.spec.ts
camdenmoors Mar 4, 2022
d101626
Don't redefine err, change debug to verbose
camdenmoors Mar 4, 2022
fb29915
[WIP] Move SplunkReader to splunk-sdk
camdenmoors Mar 4, 2022
f54c53d
Merge branch 'master' into splunkUpdates
camdenmoors Mar 11, 2022
a1492b7
Move Splunk2HDF into hdf-converters
camdenmoors Mar 11, 2022
1b390d3
Lint, wait for all files to load before closing SplunkReader
camdenmoors Mar 11, 2022
c73752d
Remove duplicate splunk-sdk
camdenmoors Mar 11, 2022
c7c0525
Address code smells
camdenmoors Mar 11, 2022
a5f0311
Use JQuery provided by HTML Export
camdenmoors Mar 11, 2022
1144dc1
Add Upload to Splunk from Heimdall
camdenmoors Mar 11, 2022
e3ac147
Merge branch 'splunkUpdates' of github.com:mitre/heimdall2 into splun…
camdenmoors Mar 11, 2022
31e5b80
Use full path to jQuery
camdenmoors Mar 11, 2022
c41964f
Merge branch 'master' into splunkUpdates
camdenmoors Mar 14, 2022
d4696fc
Fix Matching for http(s), add Refresh to Splunk FileList
camdenmoors Mar 14, 2022
b7000f8
Merge branch 'master' into splunkUpdates
camdenmoors Mar 14, 2022
18a6be8
Merge branch 'master' into splunkUpdates
camdenmoors Mar 14, 2022
1c55ae9
Fix E2E Tests, Chunk Control Uploads (100/upload), Remove Insecure Fl…
camdenmoors Mar 14, 2022
a985bb4
Merge branch 'splunkUpdates' of github.com:mitre/heimdall2 into splun…
camdenmoors Mar 14, 2022
4f43af2
Return onUpdateSearch consistently, clean execution query
camdenmoors Mar 14, 2022
8a30618
Add login timeout error
camdenmoors Mar 14, 2022
4be7f85
Add logging to splunk2hdf, remove export for local hdf2splunk variables
camdenmoors Mar 14, 2022
e180bca
Move parseSplunkResponse to a seperate function
camdenmoors Mar 14, 2022
14a093a
Mark Overlaid Controls as "Overlaid Controls" in Splunk
camdenmoors Mar 15, 2022
63846be
Update type for targetIndex
camdenmoors Mar 15, 2022
e51f6b1
!= !== !==
camdenmoors Mar 15, 2022
a5d5a1e
Allow any for Splunk types
camdenmoors Mar 15, 2022
7a2d21f
Merge branch 'master' into splunkUpdates
camdenmoors Mar 15, 2022
dfc40b4
Add Non-AJAX Mode for Splunk Mapper
camdenmoors Mar 17, 2022
4c6a2d2
Restore profile.status
camdenmoors Mar 17, 2022
3c51f65
Merge branch 'splunkUpdates' of github.com:mitre/heimdall2 into splun…
camdenmoors Mar 17, 2022
f4c0b94
Reduce complexity of checkSplunkCredentials
camdenmoors Mar 18, 2022
02d5dae
Merge branch 'master' into splunkUpdates
camdenmoors Mar 18, 2022
910b6aa
Update help message
camdenmoors Mar 18, 2022
4f5c91d
Merge branch 'splunkUpdates' of github.com:mitre/heimdall2 into splun…
camdenmoors Mar 18, 2022
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
2 changes: 2 additions & 0 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@heimdall/interfaces": "^2.6.14",
"@mdi/font": "^6.1.95",
"@mdi/js": "^6.1.95",
"@mitre/splunk-sdk-no-env": "^1.10.0",
"@types/bootstrap": "^5.0.15",
"@types/chroma-js": "^2.1.0",
"@types/concat-stream": "^2.0.0",
Expand Down Expand Up @@ -122,6 +123,7 @@
"vuetify-loader": "^1.6.0",
"vuex": "^3.1.2",
"vuex-module-decorators": "^1.0.1",
"winston": "^3.6.0",
"xlsx": "^0.17.0",
"xml-js": "^1.6.11",
"yazl": "^2.5.1"
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<script src="/static/export/jquery.min.js"></script>
<link rel="icon" href="/favicon.ico">
<title>Heimdall</title>
</head>
Expand Down
158 changes: 158 additions & 0 deletions apps/frontend/src/components/global/ExportSplunkModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<template>
<v-dialog v-model="showingModal" width="800px">
<template #activator="{on}">
<LinkItem
key="export_splunk"
text="Export to Splunk"
icon="mdi-database-arrow-up"
@click="showModal"
v-on="on"
/>
</template>
<v-card>
<v-card-title class="headline"> Export to Splunk </v-card-title>
<v-card-text>
<v-stepper v-model="step" class="elevation-0">
<v-stepper-header class="elevation-0">
<v-stepper-step id="step-1" step="1">
Login Credentials
</v-stepper-step>
<v-divider />
<v-stepper-step id="step-2" step="2"> Post Data </v-stepper-step>
</v-stepper-header>
<v-stepper-items>
<v-stepper-content step="1">
<AuthStep
index-to-show="hdf"
@authenticated="onAuthenticationComplete"
@error="errorCount += 1"
@show-help="errorCount = -1"
/>
</v-stepper-content>
<v-stepper-content step="2">
<pre v-text="statusLog" />
</v-stepper-content>
</v-stepper-items>
<v-overlay
:opacity="50"
absolute="absolute"
:value="errorCount >= 3 || errorCount < 0"
>
<div class="text-center">
<p>
<span v-if="errorCount > 0">
It seems you may be having trouble using the Splunk toolkit.
Are you sure that you have configured it properly?
</span>
<br />
<span>
For installation instructions and further information, check
here:
</span>
<v-btn
target="_blank"
href="https://github.com/mitre/hdf-json-to-splunk/"
text
color="info"
px-0
>
<v-icon pr-2>mdi-github-circle</v-icon>
Splunk HDF Plugin
</v-btn>
</p>
<v-btn color="info" @click="errorCount = 0"> Ok </v-btn>
</div>
</v-overlay>
</v-stepper>
</v-card-text>
<v-card-actions>
<v-spacer />
<v-btn text @click="closeModal"> Close </v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>

<script lang="ts">
import LinkItem from '@/components/global/sidebaritems/IconLinkItem.vue';
import {FilteredDataModule} from '@/store/data_filters';
import {FileID} from '@/store/report_intake';
import {FromHDFToSplunkMapper, SplunkConfig} from '@mitre/hdf-converters';
import Vue from 'vue';
import Component from 'vue-class-component';
import winston from 'winston';
import {SnackbarModule} from '../../store/snackbar';
import AuthStep from '../global/upload_tabs/splunk/AuthStep.vue';

@Component({
components: {
AuthStep,
LinkItem
}
})
export default class ExportSplunkModal extends Vue {
showingModal = false;
step = 1;
errorCount = 0;
statusLog = '';
splunkConfig: SplunkConfig | null = null;

logger: unknown = {
info: this.addLogMessage,
debug: this.addLogMessage,
verbose: this.addLogMessage,
error: this.addLogMessage
};

addLogMessage(message: string) {
this.statusLog += message + '\n';
}

closeModal() {
this.showingModal = false;
this.step = 1;
this.statusLog = '';
this.splunkConfig = null;
}

showModal() {
this.showingModal = true;
}

onAuthenticationComplete(splunkConfig: SplunkConfig) {
this.splunkConfig = splunkConfig;
this.step = 2;
this.convertAndUpload();
}

got_files(files: FileID[]) {
this.$emit('got-files', files);
}

onSignOut() {
this.step = 1;
this.splunkConfig = null;
}

async convertAndUpload() {
const ids = FilteredDataModule.selected_file_ids;
FilteredDataModule.evaluations(ids).forEach(async (evaluation) => {
this.statusLog += `Starting Upload of File: ${evaluation.from_file.filename}\n`;
if (this.splunkConfig) {
new FromHDFToSplunkMapper(evaluation, this.logger as winston.Logger)
.toSplunk(this.splunkConfig, evaluation.from_file.filename, true)
.then(() => {
this.statusLog += `Sucessfully uploaded file ${evaluation.from_file.filename}\n`;
})
.catch((error) => {
this.statusLog += `Failed to upload file ${evaluation.from_file.filename}:\n\t${error}\n`;
});
} else {
SnackbarModule.failure(
'Failed to upload to Splunk: Invalid Configuration (undefined)'
);
}
});
}
}
</script>
89 changes: 65 additions & 24 deletions apps/frontend/src/components/global/upload_tabs/splunk/AuthStep.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,27 @@
type="password"
data-cy="splunkpassword"
/>
<v-text-field
v-model="hostname"
label="Hostname"
for="hostname_field"
hint="https://yourdomain.com:8089"
data-cy="splunkhostname"
/>
<v-container style="margin: 0; padding: 0" grid-list-md text-xs-center>
<v-layout row wrap>
<v-flex xs10>
<v-text-field
v-model="hostname"
label="Hostname"
for="hostname_field"
hint="https://yourdomain.com:8089"
data-cy="splunkhostname"
/>
</v-flex>
<v-flex xs2>
<v-text-field
v-model="index"
label="Index"
for="index_field"
data-cy="splunkindex"
/>
</v-flex>
</v-layout>
</v-container>
</v-form>
<v-row class="mx-1">
<v-btn
Expand All @@ -44,13 +58,17 @@
import FileList from '@/components/global/upload_tabs/aws/FileList.vue';
import {SnackbarModule} from '@/store/snackbar';
import {LocalStorageVal} from '@/utilities/helper_util';
import {SplunkClient} from '@/utilities/splunk_util';
import {checkSplunkCredentials} from '@mitre/hdf-converters/src/splunk-mapper';
import {SplunkConfig} from '@mitre/splunk-sdk-no-env';
import Vue from 'vue';
import Component from 'vue-class-component';
import {Prop} from 'vue-property-decorator';

// Our saved fields
const localUsername = new LocalStorageVal<string>('splunk_username');
const localPassword = new LocalStorageVal<string>('splunk_password');
const localSplunk2HDFIndex = new LocalStorageVal<string>('splunk2hdf_index');
const localHDF2SplunkIndex = new LocalStorageVal<string>('hdf2splunk_index');
const localHostname = new LocalStorageVal<string>('splunk_hostname');

@Component({
Expand All @@ -59,37 +77,60 @@ const localHostname = new LocalStorageVal<string>('splunk_hostname');
}
})
export default class AuthStep extends Vue {
@Prop({type: String, required: false}) indexToShow?: string;
username = '';

password = '';
hostname = '';
index = '';

async login(): Promise<void> {
if (!/^https?:\/\//.test(this.hostname)) {
this.hostname = `https://${this.hostname}`;
}

const parsedURL = new URL(this.hostname);

const config: SplunkConfig = {
host: parsedURL.hostname,
username: this.username,
password: this.password,
port: parseInt(parsedURL.port) || 8089,
index: this.index,
scheme: parsedURL.protocol.split(':')[0] || 'https'
};

async login() {
const splunkClient = new SplunkClient(
this.hostname,
this.username,
this.password
);
splunkClient.validateCredentials().then((result) => {
if (result === true) {
await checkSplunkCredentials(config, true)
.then(() => {
localUsername.set(this.username);
localPassword.set(this.password);
localHostname.set(this.hostname);
if (this.indexToShow === undefined) {
localSplunk2HDFIndex.set(this.index);
} else {
localHDF2SplunkIndex.set(this.index);
}
SnackbarModule.notify('You have successfully signed in');
this.$emit('authenticated', splunkClient);
} else if (result === false) {
SnackbarModule.failure('Incorrect Username or Password');
} else {
SnackbarModule.failure(result);
this.$emit('error');
}
});
this.$emit('authenticated', config);
})
.catch((error) => {
if (error !== 'Incorrect Username or Password') {
this.$emit('error');
}
SnackbarModule.failure(error);
});
}

/** Init our fields */
mounted() {
this.username = localUsername.get_default('');
this.password = localPassword.get_default('');
this.hostname = localHostname.get_default('');
if (this.indexToShow === undefined) {
this.index = localSplunk2HDFIndex.get_default('*');
} else {
this.index = localSplunk2HDFIndex.get_default(this.indexToShow);
}
}
}
</script>
Loading