repo_name
stringlengths
5
122
path
stringlengths
3
232
text
stringlengths
6
1.05M
mason-fish/brim
src/js/state/Packets/flows.ts
import {join} from "path" import {remote} from "electron" import {Thunk} from "../types" import {saveToFile} from "../../lib/response" import Current from "../Current" import Packets from "../Packets" import View from "../View" import {getZealot} from "../../flows/getZealot" import {zng} from "zealot" export default ...
mason-fish/brim
src/js/state/Boards/index.ts
import {createEntityAdapter, createSlice, PayloadAction} from "@reduxjs/toolkit" import {initialBoard} from "ppl/summary/flows/initial-state" import {State} from "../types" export type Board = {id: string; title: string; tiles: string[]} export type BoardsState = ReturnType<typeof slice.reducer> const adapter = creat...
mason-fish/brim
src/js/test/responses/index.ts
<reponame>mason-fish/brim<filename>src/js/test/responses/index.ts import {readFileSync} from "fs" import path from "path" export default function responses(name: string) { const string = readFileSync(path.join(__dirname, name), "utf-8") return string.split("\n\n\n").map((json) => JSON.parse(json)) }
mason-fish/brim
src/js/state/Search/test.ts
import {createZealotMock} from "zealot" import Workspaces from "../Workspaces" import Current from "../Current" import Search from "./" import Spaces from "../Spaces" import Tab from "../Tab" import brim from "../../brim" import fixtures from "../../test/fixtures" import initTestStore from "../../test/initTestStore" ...
mason-fish/brim
src/js/test/setup.ts
require("regenerator-runtime/runtime") import initDOM from "../initializers/initDOM" const Adapter = require("enzyme-adapter-react-16") const enzyme = require("enzyme") jest.mock("electron", function() { class FakeBrowserWindow { webContents: {send: any} constructor() { this.webContents = {send: jes...
mason-fish/brim
zealot/fetcher/stream.ts
<reponame>mason-fish/brim import {createCallbacks} from "./callbacks" import {ZCallbacks, ZIterator} from "../types" import * as zjson from "../zjson" import * as zng from "../zng" async function emitCallbacks(iterator: ZIterator, callbacks: ZCallbacks) { try { for await (const payload of iterator) { callb...
mason-fish/brim
src/js/components/LogDetails/ColumnDescription.tsx
<filename>src/js/components/LogDetails/ColumnDescription.tsx import MarkdownIt from "markdown-it" import React from "react" import {Column} from "../../types" import open from "../../lib/open" import zeekLogInfo from "ppl/zeek/logInfo" type Props = { column: Column path: string } export default function ColumnDe...
mason-fish/brim
src/js/components/TabBar/useTabController.ts
import {useDispatch, useSelector} from "react-redux" import {useEffect, useRef, useState} from "react" import onIdle from "on-idle" import Tabs from "../../state/Tabs" import {ipcRenderer} from "electron" export default function(count: number, calcWidths: Function) { const trueActiveId = useSelector(Tabs.getActive)...
mason-fish/brim
src/js/state/Prefs/reducer.ts
import {PrefsAction, PrefsState} from "./types" const init: PrefsState = { jsonTypeConfig: "", timeFormat: "", suricataRunner: "", suricataUpdater: "", zeekRunner: "", dataDir: "" } export default function reducer( state: PrefsState = init, action: PrefsAction ): PrefsState { switch (action.type) { ...
mason-fish/brim
src/js/state/Columns/touch.test.ts
<filename>src/js/state/Columns/touch.test.ts<gh_stars>0 import {createColumn} from "./models/column" import Columns from "./" import actions from "./actions" import initTestStore from "../../test/initTestStore" import touch from "./touch" import {zng} from "zealot" const columns = { "1": new zng.Schema([ {name: ...
mason-fish/brim
test/api/helper/test_api.ts
import {createZealot} from "./mod.ts" import { join, fromFileUrl, dirname } from "https://deno.land/std@0.70.0/path/mod.ts" const DIR = dirname(fromFileUrl(import.meta.url)) const ZQD_ROOT = join(DIR, "../zqd_root") const ZEEK_RUNNER = join(DIR, "../../../zdeps/zeek/zeekrunner") const ZQD_RUNNER = join(DIR, "../...
mason-fish/brim
src/js/state/Tabs/actions.ts
import { AddTabData, TABS_ACTIVATE, TABS_ACTIVE_CLEAR, TABS_ADD, TABS_MOVE, TABS_ORDER, TABS_REMOVE } from "./types" export default { add: (id: string, data?: AddTabData): TABS_ADD => ({ type: "TABS_ADD", id, data }), remove: (id: string): TABS_REMOVE => ({ type: "TABS_REMOVE", ...
mason-fish/brim
src/js/components/Tables/VerticalTable.tsx
import React from "react" import classNames from "classnames" import Table, {TableData, TableHeader} from "./Table" import {zjson, zng} from "zealot" type Props = { descriptor: zjson.Column[] record: zng.Record onRightClick?: (f: zng.Field, r: zng.Record) => void light?: boolean } export default function Ver...
mason-fish/brim
src/js/electron/appPathSetup.ts
<reponame>mason-fish/brim import {app} from "electron" import log from "electron-log" import electronIsDev from "./isDev" import path from "path" // setupPaths must be called very early in startup, before the app 'ready' // event fires, to ensure any Electron state is recorded to the intended // locations. export func...
mason-fish/brim
ppl/detail/flows/getCorrelationQuery.ts
import { cidCorrelation, connCorrelation, uidCorrelation } from "src/js/searches/programs" import {zng} from "zealot" import {Correlation} from "../models/Correlation" export function getCorrelationQuery(record: zng.Record) { const {uid, cid} = new Correlation(record).getIds() if (cid && uid) { return c...
mason-fish/brim
src/js/state/Last/test.ts
<gh_stars>0 import Last from "./" import initTestStore from "../../test/initTestStore" import {SearchRecord} from "src/js/types" let store, select, dispatch beforeEach(() => { store = initTestStore() select = (s) => s(store.getState()) dispatch = store.dispatch }) test("initial state is null", () => { expect...
mason-fish/brim
zealot/api/archive.ts
<reponame>mason-fish/brim<filename>zealot/api/archive.ts import {FetchArgs} from "../fetcher/fetcher" export type IndexSearchArgs = { spaceId: string patterns: string[] index_name?: string signal?: AbortSignal } export function search({ spaceId, index_name, patterns, signal }: IndexSearchArgs): FetchA...
mason-fish/brim
zealot/zealot.ts
import {createFetcher} from "./fetcher/fetcher" import {spaces, logs, pcaps, search, archive, subspaces} from "./api/mod" import {getHost} from "./util/host" import {getDefaultSearchArgs} from "./config/search_args" import { SearchArgs, SpaceArgs, PcapsPostArgs, PcapsGetArgs, LogsPostArgs, ZealotArgs, Sub...
mason-fish/brim
src/js/brim/space.ts
<gh_stars>0 import {Space} from "../state/Spaces/types" import {isNumber} from "../lib/is" import brim, {Ts, Span} from "./" export default function space(info: Space) { return { ...info, isArchive() { return this.getType() === "archive" }, hasIndex() { return info.storage_kind !== "files...
mason-fish/brim
src/js/state/Tiles/test.ts
import initTestStore from "src/js/test/initTestStore" import Tiles, {Tile} from "./index" let s, d beforeEach(() => { const store = initTestStore() d = store.dispatch s = (f) => f(store.getState()) }) /* Skipping tests until security summary is shipped */ test.skip("initial state", () => { const tiles = s(Ti...
mason-fish/brim
src/js/flows/submitSearch/__tests__/index.test.ts
<filename>src/js/flows/submitSearch/__tests__/index.test.ts import {createZealotMock, zng} from "zealot" import {submitSearch} from "../mod" import Columns from "../../../state/Columns" import Current from "../../../state/Current" import Handlers from "../../../state/Handlers" import SearchBar from "../../../state/Sea...
mason-fish/brim
itest/lib/appStep/api/startApp.ts
import {Application} from "spectron" import logStep from "../util//logStep" import {selectors} from "../../../../src/js/test/integration" export const waitForNewTab = (app: Application) => logStep("wait for new tab to appear", async () => (await app.client.$(selectors.ingest.filesButton)).waitForDisplayed() )...
mason-fish/brim
src/js/state/SearchBar/reducer.ts
<gh_stars>0 import {SearchBarAction, SearchBarState} from "./types" import {indexInBounds} from "../../lib/Array" import {onlyWhitespace} from "../../lib/Str" const init: SearchBarState = { current: "", previous: "", pinned: [], editing: null, error: null, target: "events" } export default function reduce...
mason-fish/brim
zealot/zqd.ts
import {Ts} from "./types" import * as zjson from "./zjson" export type Payload = | SearchRecords | SearchWarnings | SearchStats | SearchEnd | TaskStart | TaskEnd | PcapPostStatus export type SearchRecords = { type: "SearchRecords" records: zjson.Items channel_id: number } export type SearchWarni...
mason-fish/brim
zealot/fetcher/records_callback.ts
import * as zjson from "../zjson" import * as zng from "../zng" import * as zqd from "../zqd" export interface RecordsCallbackArgs { channel: number schemas: SchemaMap newRecords: zng.Record[] allRecords: zng.Record[] } type SchemaMap = Map<number, zng.Schema> type ChannelMap = Map<number, Channel> type Channe...
mason-fish/brim
src/js/test/initTestStore.ts
import {configureStore} from "@reduxjs/toolkit" import {createZealotMock, Zealot} from "zealot" import rootReducer from "../state/rootReducer" import {Action, State} from "../state/types" export type TestStore = { dispatch: Function dispatchAll: Function getActions: Function getActionTypes: Function clearAct...
mason-fish/brim
src/js/components/Span/SpanPicker.tsx
import {useDispatch} from "react-redux" import React from "react" import {reactElementProps} from "../../test/integration" import PopMenuPointy from "../PopMenu/PopMenuPointy" import ToolbarButton from "../../../../app/toolbar/button" import refreshSpaceInfo from "../../flows/refreshSpaceInfo" import useSpanPickerMenu...
mason-fish/brim
zealot/zng/ts_types.ts
<reponame>mason-fish/brim import {Record} from "./types/record" import {ZArray} from "./types/array" import {Union} from "./types/union" import {Primitive} from "./types/primitive" import {Set} from "./types/set" import {zjson} from ".." export type Type = Record | ZArray | Set | Union | Primitive export type Containe...
mason-fish/brim
zealot/api/search.ts
import {parse} from "../zql" import {createSpan} from "../util/span" import {SearchArgs} from "../types" import {FetchArgs} from "../fetcher/fetcher" export default function searchApi(zql: string, args: SearchArgs): FetchArgs { return { method: "POST", path: `/search?${getQueryParams(args)}`, body: JSON....
mason-fish/brim
src/js/electron/tron/windowManager.test.ts
import {ipcMain} from "electron" import tron from "./" test("serialize each window", async () => { const manager = tron.windowManager() manager.openWindow("search") // @ts-ignore ipcMain.once.mockReset() setTimeout(() => { // @ts-ignore const [_replyChan, callback] = ipcMain.once.mock.calls[0] ca...
mason-fish/brim
app/toolbar/action-buttons.tsx
<filename>app/toolbar/action-buttons.tsx import React, {RefCallback} from "react" import styled from "styled-components" import ActionButton, {ActionButtonProps} from "./action-button" type Justify = "center" | "flex-end" export const GUTTER = 8 const BG = styled.div<{justify: Justify}>` display: flex; justify-c...
mason-fish/brim
ppl/summary/grid.tsx
import {cssVar, transparentize} from "polished" import React from "react" import styled from "styled-components" import GridLayout from "react-grid-layout" import {ParentSize} from "@vx/responsive" const BG = styled.div` height: 100%; .react-grid-placeholder { opacity: 1; background: ${transparentize(0.99,...
mason-fish/brim
ppl/detail/flows/fetch.test.ts
<reponame>mason-fish/brim import {last} from "lodash" import {zng} from "zealot" import loginTo from "src/js/test/helpers/loginTo" import {fetchCorrelation} from "./fetch" import * as stubs from "./stubs" const zeek = new zng.Record( [ {name: "_path", type: "string"}, {name: "uid", type: "string"} ], ["d...
mason-fish/brim
src/js/flows/scrollToLog.ts
import {Thunk} from "../state/types" import Viewer from "../state/Viewer" import {isEqual} from "lodash" import {zng} from "zealot" export default (log: zng.Record): Thunk => (dispatch, getState) => { const state = getState() const logs = Viewer.getLogs(state) const index = logs.findIndex((log2) => isEqual(log2,...
mason-fish/brim
src/js/errors/types.ts
export type BrimErrorType = | "PCAPIngestError" | "NetworkError" | "LogsIngestError" | "SpaceDeletedError" export type BrimError = { type: BrimErrorType message: string details?: string[] }
mason-fish/brim
src/js/state/Last/types.ts
import {SearchRecord} from "../../types" export type LastState = { search: SearchRecord | null | undefined } export type LastAction = LAST_SEARCH_SET export type LAST_SEARCH_SET = {type: "LAST_SEARCH_SET"; search: SearchRecord}
mason-fish/brim
src/js/components/LeftPane/SpacesSection.tsx
<filename>src/js/components/LeftPane/SpacesSection.tsx<gh_stars>0 import {useSelector} from "react-redux" import Current from "../../state/Current" import get from "lodash/get" import WorkspaceStatuses from "../../state/WorkspaceStatuses" import Spaces from "../../state/Spaces" import AddSpaceButton from "../AddSpaceBu...
mason-fish/brim
src/js/search.tsx
import "regenerator-runtime/runtime" import {Provider} from "react-redux" import {ThemeProvider} from "styled-components" import React from "react" import ReactDOM from "react-dom" import App from "./components/App" import AppErrorBoundary from "./components/AppErrorBoundary" import StartupError from "./components/St...
mason-fish/brim
src/js/components/LeftPane/QueriesSection.tsx
<gh_stars>0 import {MenuItemConstructorOptions, remote} from "electron" import {includes} from "lodash" import React, {useEffect, useState} from "react" import {useDispatch, useSelector} from "react-redux" import TreeModel from "tree-model" import {TreeList} from "../../../pkg/tree-list" import {submitSearch} from "../...
mason-fish/brim
src/js/state/Spaces/test.ts
import Spaces from "./" import initTestStore from "../../test/initTestStore" import {Space} from "./types" let store beforeEach(() => { store = initTestStore() }) const detail = { id: "defaultId", name: "defaultName", span: { ts: {sec: 1425564900, ns: 0}, dur: {sec: 3352893, ns: 750000000} }, pcap...
mason-fish/brim
src/js/electron/ipc/windows/mainHandler.ts
<gh_stars>0 import log from "electron-log" import {BrowserWindow, dialog, ipcMain} from "electron" import {Brim} from "../../brim" let started = false export default function(brim: Brim) { ipcMain.handle("windows:initialState", (_e, {id}) => { const window = brim.windows.getWindow(id) return window.initial...
mason-fish/brim
src/js/state/types.ts
import {Store as ReduxStore, Action as ReduxAction} from "redux" import {ThunkAction, ThunkDispatch} from "redux-thunk" import {ErrorsState} from "./Errors/types" import {HandlersState} from "./Handlers/types" import {InvestigationState} from "./Investigation/types" import {ModalState} from "./Modal/types" import {Noti...
mason-fish/brim
zealot/zjson.ts
<reponame>mason-fish/brim export interface Item { id: number schema?: Schema aliases?: PrimitiveColumn[] values: Value[] } export type Items = Item[] export type Schema = Record export type Type = Primitive | Record | Array | Set | Union export type Column = | PrimitiveColumn | RecordColumn | ArrayColumn...
mason-fish/brim
src/js/brim/space.test.ts
import brim from "./" import fixtures from "../test/fixtures" const space = fixtures("space1") test("default time span is 30 mins before max time", () => { const span = brim.space(space).defaultSpanArgs() expect(span).toEqual([ { sec: 1428915994, ns: 0 }, { sec: 1428917794, ns:...
mason-fish/brim
src/js/components/useSpanPickerMenu.ts
import {useDispatch, useSelector} from "react-redux" import {DateTuple, spanOfLast} from "../lib/TimeWindow" import {submitSearch} from "../flows/submitSearch/mod" import Current from "../state/Current" import Search from "../state/Search" import brim from "../brim" export default function useSpanPickerMenu() { con...
mason-fish/brim
src/js/components/charts/pens/barStacks.ts
import * as d3 from "d3" import {Pen} from "../types" import {d3ElementAttr, itestLocator} from "../../../test/integration" import {innerHeight, innerWidth} from "../dimens" import brim from "../../../brim" export default function(): Pen { let chartG function mount(svg) { chartG = d3 .select(svg) ...
mason-fish/brim
src/js/state/SearchBar/test.ts
<reponame>mason-fish/brim import {createZealotMock, zng} from "zealot" import { appendQueryCountBy, appendQueryExclude, appendQueryInclude } from "../../flows/searchBar/actions" import {submitSearch} from "../../flows/submitSearch/mod" import Workspaces from "../Workspaces" import Current from "../Current" impor...
mason-fish/brim
src/js/components/Span/TimeInput.tsx
<filename>src/js/components/Span/TimeInput.tsx import {useSelector} from "react-redux" import React, {useEffect, useRef, useState} from "react" import {SPAN_TIME_FMT} from "./SpanControls" import {TimeArg} from "../../state/Search/types" import {isString} from "../../lib/is" import Form from "../form/Form" import View...
mason-fish/brim
app/tile/tile.tsx
<filename>app/tile/tile.tsx import useSearch from "app/core/hooks/useSearch" import React, {forwardRef} from "react" import styled from "styled-components" import {useSelector} from "react-redux" import Current from "src/js/state/Current" import Tab from "src/js/state/Tab" import MenuButton from "./menu-button" import ...
mason-fish/brim
src/js/components/Preferences/JSONTypeConfig.tsx
<gh_stars>0 import React from "react" import {FormFieldConfig} from "../../brim/form" import {jsonTypeConfigInput} from "../../test/locators" import FileInput from "../common/forms/FileInput" import InputLabel from "../common/forms/InputLabel" import Link from "../common/Link" type Props = { config: FormFieldConfig...
mason-fish/brim
zealot/index.ts
<gh_stars>0 import {createFetcher, FetchArgs} from "./fetcher/fetcher" import {Zealot, ZealotPayload, SearchFormat} from "./types" import {createTime} from "./util/time" import {createZealot} from "./zealot" import {createZealotMock, ZealotMock} from "./zealot_mock" import * as zjson from "./zjson" import * as zng from...
mason-fish/brim
src/js/flows/createSubspace.ts
<reponame>mason-fish/brim import {Thunk} from "../state/types" import {createSpaceName} from "../brim/spaceName" import {getUniqName} from "../lib/uniqName" import {getZealot} from "./getZealot" import Current from "../state/Current" import Spaces from "../state/Spaces" import Tabs from "../state/Tabs" import Viewer fr...
mason-fish/brim
src/js/components/charts/MainHistogram/useMainHistogram.tsx
<reponame>mason-fish/brim<filename>src/js/components/charts/MainHistogram/useMainHistogram.tsx import {useDispatch, useSelector} from "react-redux" import React, {useMemo} from "react" import * as d3 from "d3" import {DateTuple} from "../../../lib/TimeWindow" import {Pen, HistogramChart} from "../types" import {innerH...
mason-fish/brim
app/core/icons/index.ts
<gh_stars>0 import threeDots from "./three-dots.svg" import chart from "./chart.svg" import grid from "./grid.svg" import list from "./list.svg" import view from "./view.svg" import sharkfin from "./sharkfin.svg" import exportIcon from "./export.svg" import columns from "./columns.svg" import chevronDown from "./chevro...
mason-fish/brim
test/api/pcaps_test.ts
import {testApi, testFile, assertEquals, createTime} from "./helper/mod.ts" async function setup(zealot: any) { const space = await zealot.spaces.create({name: "my-pcaps"}) const path = testFile("sample.pcap") const resp = await zealot.pcaps.post({spaceId: space.id, path}) await resp.array() zealot.setSearch...
mason-fish/brim
ppl/summary/horizontal-bar-chart.tsx
<filename>ppl/summary/horizontal-bar-chart.tsx import React from "react" import {zng} from "zealot" import {BarRounded} from "@vx/shape" import {AxisLeft, AxisBottom} from "@vx/axis" import {scaleLinear, scaleBand} from "@vx/scale" import {Group} from "@vx/group" import {cssVar} from "src/js/lib/cssVar" import styled f...
mason-fish/brim
src/js/brim/interop.ts
<reponame>mason-fish/brim import brim, {Ts} from "./" export default { spacePayloadToSpace(space: any) { if (space.span) { const span = space.span const end = brim .time(span.ts) .addTs(span.dur as Ts) .toTs() space = {...space, min_time: span.ts, max_time: end} de...
mason-fish/brim
src/js/flows/deleteSpace.ts
import {Thunk} from "../state/types" import {getZealot} from "./getZealot" import Current from "../state/Current" import Investigation from "../state/Investigation" import Spaces from "../state/Spaces" const deleteSpace = (id: string): Thunk<Promise<void>> => ( dispatch, getState ) => { const zealot = dispatch(g...
mason-fish/brim
zealot/ndjson/pipe_text.ts
export async function* pipeText(stream: ReadableStream<Uint8Array> | null) { if (!stream) return let reader = stream.getReader() let text = new TextDecoder() try { while (true) { let {done, value} = await reader.read() if (!done && value) { yield text.decode(value) } else { ...
mason-fish/brim
src/js/components/Viewer/Header.tsx
import {useSelector} from "react-redux" import React, {useMemo} from "react" import {ViewerDimens} from "../../types" import HeaderCell from "./HeaderCell" import SearchBar from "../../state/SearchBar" import * as Styler from "./Styler" import TableColumns from "../../models/TableColumns" import brim from "../../brim"...
mason-fish/brim
src/js/state/Packets/reducer.ts
import {Download, PacketsAction, PacketsState} from "./types" const init: PacketsState = [] export default function reducer( state: PacketsState = init, action: PacketsAction ): PacketsState { switch (action.type) { case "PACKETS_REQUEST": return [initDownload(action.uid), ...state] case "PACKETS...
mason-fish/brim
src/js/state/migrations/202007151457_addScrollPosToSearchRecord.test.ts
import {migrate} from "src/js/test/helpers/migrate" test("migrating 202007151457_addScrollPosToSearchRecord", async () => { const next = await migrate({state: "v0.13.1", to: "202007151457"}) const windows = Object.values(next.windows) for (const win of windows) { // @ts-ignore for (const tab of win.sta...
mason-fish/brim
ppl/detail/models/SuricataEvent.ts
import {zng} from "zealot" import {BrimEventInterface} from "./BrimEvent" export class SuricataEvent implements BrimEventInterface { constructor(private r: zng.Record) {} getRecord() { return this.r } getTime() { return (this.r.get("ts") as zng.Primitive).toDate() } getEndTime() { return nul...
mason-fish/brim
src/js/state/migrations/202005151706_addZeekRunnerPref.ts
<reponame>mason-fish/brim import {getAllStates} from "../../test/helpers/getTestState" export default function addZeekRunnerPref(state: any) { for (const s of getAllStates(state)) { s.prefs.zeekRunner = "" } return state }
mason-fish/brim
app/toolbar/hooks/usePackets.ts
<gh_stars>0 import {useState} from "react" import {useDispatch, useSelector} from "react-redux" import useDebouncedEffect from "src/js/components/hooks/useDebouncedEffect" import {downloadPcap} from "src/js/flows/downloadPcap" import Current from "src/js/state/Current" import LogDetails from "src/js/state/LogDetails" i...
mason-fish/brim
src/js/state/Tabs/types.ts
<reponame>mason-fish/brim<gh_stars>0 import {TabState} from "../Tab/types" export type TabsState = {active: string; data: TabState[]} export type TabActions = | TABS_ADD | TABS_REMOVE | TABS_ACTIVATE | TABS_MOVE | TABS_ORDER | TABS_ACTIVE_CLEAR export type AddTabData = { workspaceId: string | null spa...
mason-fish/brim
src/js/electron/tron/migrations.ts
<reponame>mason-fish/brim<gh_stars>0 import path from "path" import {last} from "../../lib/Array" import lib from "../../lib" const dir = path.join(__dirname, "../../state/migrations") type Migration = { version: number migrate: Function } type VersionedData = { version: number data: any } export type Migr...
mason-fish/brim
src/js/state/migrations/202008031645_removeViewerSlice.test.ts
<gh_stars>0 import {migrate} from "src/js/test/helpers/migrate" test("migrating 202008031645_removeViewerSlice", async () => { const next = await migrate({state: "v0.14.0", to: "202008031645"}) const windows = Object.values(next.windows) for (const win of windows) { // @ts-ignore for (const tab of win....
mason-fish/brim
src/js/test/mockZealot.ts
export default { spaces: { create: () => Promise.resolve({name: "dataSpace"}), list: () => Promise.resolve(["dataSpace"]), get: () => Promise.resolve({ name: "dataSpace", min_time: {ns: 0, sec: 0}, max_time: {ns: 1, sec: 1}, pcap_support: true }) }, pcaps: {...
mason-fish/brim
src/js/components/hooks/useListener.ts
import {useEffect} from "react" export default function useListener( el: Node | null | undefined, event: string, callback: EventListenerOrEventListenerObject, opts: boolean | Object = false ) { useEffect(() => { el && el.addEventListener(event, callback, opts) return () => { if (el) el.removeEv...
mason-fish/brim
src/js/components/LogDetailsWindow/index.tsx
import {useDispatch, useSelector} from "react-redux" import React from "react" import {Center, Left, PaneHeader, PaneTitle, Right} from "../Pane" import Current from "../../state/Current" import HistoryButtons from "../common/HistoryButtons" import LogDetails from "../../state/LogDetails" import DetailPane from "app/d...
mason-fish/brim
src/js/components/Investigation/useFindings.ts
import {useMemo} from "react" import {useSelector} from "react-redux" import Investigation from "../../state/Investigation" import brim from "../../brim" import Current from "../../state/Current" export function useFindings() { const workspaceId = useSelector(Current.getWorkspaceId) const spaceId = useSelector(Cu...
mason-fish/brim
src/js/state/migrations/202009121941_refactorInvestigations.ts
import {getAllStates} from "../../test/helpers/getTestState" export default function refactorInvestigations(state: any) { for (const s of getAllStates(state)) { const newState = {} s.investigation.forEach((f) => { if (!f) return if (!newState[f.search.spaceId]) newState[f.search.spaceId] = [] ...
mason-fish/brim
itest/lib/appStep/util/logStep.ts
<gh_stars>100-1000 import {LOG} from "../../log" // Use this to wrap steps around log messages. It's helpful to follow // these steps along in a log file for debugging purposes. export default async (stepMessage: string, f: Function) => { LOG.debug(`Starting step "${stepMessage}"`) const result = await f() LOG.d...
mason-fish/brim
ppl/detail/flows/stubs.ts
import {ZealotPayload} from "zealot" export const uidAndCommunityResult: ZealotPayload[] = [ {type: "TaskStart", task_id: 0}, { type: "SearchRecords", channel_id: 0, records: [ { id: 34, schema: { of: [ {name: "_path", type: "string"}, {name: "ts...
mason-fish/brim
src/js/state/Packets/actions.ts
<gh_stars>0 import {PACKETS_ERROR, PACKETS_RECEIVE, PACKETS_REQUEST} from "./types" export default { request: (uid: string): PACKETS_REQUEST => ({ type: "PACKETS_REQUEST", uid }), receive: (uid: string, fileName: string): PACKETS_RECEIVE => ({ type: "PACKETS_RECEIVE", uid, fileName }), ...
mason-fish/brim
src/js/components/SearchResults/SearchResults.tsx
import {useSelector} from "react-redux" import React from "react" import {XResultsTable} from "./ResultsTable" import {useResizeObserver} from "../hooks/useResizeObserver" import Last from "../../state/Last" export default function SearchResults() { const {ref, rect} = useResizeObserver() const last = useSelector...
mason-fish/brim
zealot/config/json_types.ts
export function getDefaultJsonTypeConfig() { return { descriptors: { broker_log: [ { name: "_path", type: "string" }, { name: "ts", type: "time" }, { name: "ty", type: "zenum" }, { n...
mason-fish/brim
itest/lib/appStep/api/setSpan.ts
import {Application} from "spectron" import {click} from "./click" import logStep from "../util/logStep" import waitForResults from "../util/waitForResults" import {selectors} from "../../../../src/js/test/integration" export default async (app: Application, span: string) => { // Set the span given by "string", lik...
mason-fish/brim
src/js/flows/searches/viewerSearch.ts
<reponame>mason-fish/brim<filename>src/js/flows/searches/viewerSearch.ts<gh_stars>0 import {ANALYTIC_MAX_RESULTS, PER_PAGE} from "../config" import {SearchTarget} from "../../state/SearchBar/types" import {Thunk} from "../../state/types" import {search} from "../search/mod" import Columns from "../../state/Columns" imp...
mason-fish/brim
src/js/state/History/actions.ts
<filename>src/js/state/History/actions.ts import { HISTORY_BACK, HISTORY_CLEAR, HISTORY_FORWARD, HISTORY_PUSH, HISTORY_UPDATE } from "./types" import {ScrollPosition, SearchRecord} from "../../types" import brim, {Ts} from "../../brim" export default { back: (): HISTORY_BACK => ({ type: "HISTORY_BACK" ...
mason-fish/brim
src/js/flows/ingestFiles.ts
import {isEmpty} from "lodash" import fsExtra from "fs-extra" import {Thunk} from "../state/types" import Current from "../state/Current" import Handlers from "../state/Handlers" import Prefs from "../state/Prefs" import Spaces from "../state/Spaces" import Tabs from "../state/Tabs" import brim from "../brim" import e...
mason-fish/brim
src/js/state/View/selectors.ts
<filename>src/js/state/View/selectors.ts import {State} from "../types" export default { getDownloadsIsOpen: (state: State) => state.view.downloadsIsOpen, getTimeZone: (state: State) => state.view.timeZone }
mason-fish/brim
ppl/summary/flows/update-tile-layout.ts
import Tiles from "src/js/state/Tiles" export default (layout) => (_d, _gs, {dispatch}) => { const updates = layout.map(({x, y, h, w, i}) => ({ id: i, changes: {layout: {x, y, h, w}} })) dispatch(Tiles.updateMany(updates)) }
mason-fish/brim
src/js/components/TabSearch.tsx
<reponame>mason-fish/brim import Summary from "ppl/summary/summary" import React from "react" import {useSelector} from "react-redux" import Feature from "../state/Feature" import Layout from "../state/Layout" import {XDownloadProgress} from "./DownloadProgress" import IngestRefresh from "./IngestRefresh" import Search...
mason-fish/brim
src/js/state/Prefs/selectors.ts
import {State} from "../types" export default { getJSONTypeConfig: (state: State) => state.prefs.jsonTypeConfig, getTimeFormat: (state: State) => state.prefs.timeFormat, getSuricataRunner: (state: State) => state.prefs.suricataRunner, getSuricataUpdater: (state: State) => state.prefs.suricataUpdater, getZeek...
mason-fish/brim
src/js/flows/deletePartialSpaces.ts
<reponame>mason-fish/brim import {Thunk} from "../state/types" import Handlers from "../state/Handlers" import rpc from "../electron/rpc" import {getZealot} from "./getZealot" import Current from "../state/Current" export default (): Thunk<Promise<any[]>> => (dispatch, getState) => { const current = Current.getWorks...
mason-fish/brim
src/js/flows/exportResults.ts
<gh_stars>0 import {Thunk} from "../state/types" import {saveToFile} from "../lib/response" import Columns from "../state/Columns" import Current from "../state/Current" import SearchBar from "../state/SearchBar" import Tab from "../state/Tab" import brim from "../brim" import {SearchFormat} from "zealot" import {getZe...
mason-fish/brim
src/js/components/LogCell/index.tsx
import React, {useState} from "react" import classNames from "classnames" import {RightClickBuilder} from "../../types" import CompoundField from "./CompoundField" import SingleField from "./SingleField" import Tooltip from "../Tooltip" import {zng} from "zealot" type Props = { field: zng.Field log: zng.Record ...
mason-fish/brim
src/js/lib/columnOrder.ts
<filename>src/js/lib/columnOrder.ts import {$Column} from "../state/Columns/models/column" const EXCLUDED = ["ts", "event_type", "_path"] export default (cols: $Column[]) => { let orderedCols = cols.filter(({name}) => !EXCLUDED.includes(name)) const ts = cols.find(({name}) => name === "ts") const eventType = co...
mason-fish/brim
itest/tests/histogram.test.ts
import {basename} from "path" import appStep from "../lib/appStep/api" import newAppInstance from "../lib/newAppInstance" import {retryUntil} from "../lib/control" import {handleError, stdTest} from "../lib/jest" import {selectors} from "../../src/js/test/integration" import {LOG} from "../lib/log" describe("Histogra...
mason-fish/brim
src/js/state/migrations/202101210823_renameToWorkspace.ts
import {getAllStates} from "../../test/helpers/getTestState" export default function renameToWorkspace(state: any) { // global: clusters -> workspaces if (state) { const oldState = {...state.globalState.cluster} // remove password and username Object.values(oldState).forEach((c: any) => { delete ...
mason-fish/brim
src/js/flows/renameSpace.ts
<filename>src/js/flows/renameSpace.ts<gh_stars>0 import {Thunk} from "../state/types" import Current from "../state/Current" import Spaces from "../state/Spaces" import Tabs from "../state/Tabs" import {getZealot} from "./getZealot" export default ( workspaceId: string, spaceId: string, name: string ): Thunk<Pro...
mason-fish/brim
itest/lib/appStep/api/reload.ts
<reponame>mason-fish/brim<gh_stars>0 import {Application} from "spectron" import logStep from "../util/logStep" import {retry} from "../../control" export default (app: Application) => // Issue a browser window reload(). This is flaky in the Spectron, // Chromedriver stack, but appears be contained within the met...
mason-fish/brim
src/js/flows/initNewTab.ts
<reponame>mason-fish/brim import {Thunk} from "../state/types" import Current from "../state/Current" import Tabs from "../state/Tabs" import refreshSpaceNames from "./refreshSpaceNames" export default (): Thunk => (dispatch, getState) => { const state = getState() const space = Current.getSpace(state) const spa...
mason-fish/brim
src/js/components/TabSearchLoading.tsx
<reponame>mason-fish/brim<filename>src/js/components/TabSearchLoading.tsx import React from "react" import MacSpinner from "./MacSpinner" export default function TabSearchLoading() { return ( <div className="tab-search-loading"> <div className="message"> <p>Waiting for space to become queryable......
mason-fish/brim
src/js/state/migrations/202005181140_searchStateSpaceId.test.ts
import getTestState from "../../test/helpers/getTestState" import migrate from "./202005181140_searchStateSpaceId" const getWinStates = (sess) => Object.values(sess.windows).map((w: any) => w.state) const getTabs = (state) => state.tabs.data const getNameId = (tab) => [tab.search.spaceName, tab.search.spaceId] test...
mason-fish/brim
src/js/state/Current/types.ts
<filename>src/js/state/Current/types.ts<gh_stars>0 export type CurrentState = { workspaceId: string | null spaceId: string | null } export type CurrentAction = CURRENT_SPACE_SET | CURRENT_WORKSPACE_SET export type CURRENT_SPACE_SET = { type: "CURRENT_SPACE_SET" id: string | null } export type CURRENT_WORKSPA...
mason-fish/brim
src/js/flows/refreshSpaceInfo.ts
<gh_stars>0 import {Thunk} from "../state/types" import Current from "../state/Current" import Spaces from "../state/Spaces" import {getZealot} from "./getZealot" export default function refreshSpaceInfo(): Thunk { return () => (dispatch, getState) => { const zealot = dispatch(getZealot()) const id = Current...
mason-fish/brim
src/js/initializers/initIpcListeners.ts
<filename>src/js/initializers/initIpcListeners.ts import {ipcRenderer} from "electron" import {AppDispatch, Store} from "../state/types" import Layout from "../state/Layout" import Modal from "../state/Modal" import SearchBar from "../state/SearchBar" import Tabs from "../state/Tabs" import initNewSearchTab from "./in...