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

Add Setting for folder to store extracted pcap slices #3053

Merged
merged 1 commit into from
Apr 23, 2024
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 apps/zui/src/domain/configurations/plugin-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type ConfigItem = {
command?: string
defaultValue?: string | boolean
enum?: string[] | [string, string][]
placeholder?: string
}

export type Config = {
Expand Down
1 change: 1 addition & 0 deletions apps/zui/src/plugins/brimcap/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const pluginNamespace = "brimcap"
export const yamlConfigPropName = "yamlConfigPath"
export const suricataLocalRulesPropName = "suricataLocalRulesPath"
export const pcapFolderPropName = "pcapExtractionFolderPath"
8 changes: 8 additions & 0 deletions apps/zui/src/plugins/brimcap/configurations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
pluginNamespace,
yamlConfigPropName,
suricataLocalRulesPropName,
pcapFolderPropName,
} from "./config"
import {configurations} from "src/zui"

Expand All @@ -26,6 +27,13 @@ export function activateBrimcapConfigurations() {
label: "Local Suricata Rules Folder",
defaultValue: "",
},
[pcapFolderPropName]: {
name: pcapFolderPropName,
type: "folder",
label: "Folder For Extracted pcaps",
defaultValue: "",
placeholder: "Default OS tmpdir",
},
},
})
}
6 changes: 5 additions & 1 deletion apps/zui/src/plugins/brimcap/packets/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {window, commands} from "src/zui"
import {queryForConnLog} from "./query-conn-log"
import {DOWNLOAD} from "./types"
import {shell} from "electron"
import {configurations} from "src/zui"
import {pluginNamespace, pcapFolderPropName} from "../config"

function getSearchArgsFromConn(conn: zed.Record) {
const dur = conn.try("duration") as zed.Duration
Expand All @@ -22,7 +24,9 @@ function getSearchArgsFromConn(conn: zed.Record) {

function getPacketDest(conn: zed.Record) {
const tsString = conn.get("ts").toString()
return join(os.tmpdir(), `packets-${tsString}.pcap`.replace(/:/g, "_"))
const pcapExtractionDir =
configurations.get(pluginNamespace, pcapFolderPropName) || os.tmpdir()
return join(pcapExtractionDir, `packets-${tsString}.pcap`.replace(/:/g, "_"))
}

export async function downloadPackets(root: string, pool: string, uid: string) {
Expand Down
2 changes: 1 addition & 1 deletion apps/zui/src/views/settings-modal/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function Input(props: SettingProps) {
type="text"
defaultValue={value}
onBlur={onChange}
placeholder="None"
placeholder={field.placeholder || "None"}
/>
<button
onClick={async () => {
Expand Down
Loading