Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
Release 0.9.4
Browse files Browse the repository at this point in the history
  • Loading branch information
GoldingAustin committed Oct 1, 2023
1 parent 4cc3c1c commit 5440f9b
Show file tree
Hide file tree
Showing 8 changed files with 219 additions and 202 deletions.
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ FROM node:18-bullseye as redeye-builder
WORKDIR /app
COPY ./ ./
ENV CYPRESS_INSTALL_BINARY=0
RUN npm install -g pkg
RUN yarn add rimraf
RUN npm install -g pkg rimraf
RUN yarn install --immutable --inline-builds
RUN yarn moon run server:build client:build
RUN yarn node scripts/create-release.mjs
RUN bash create-release.sh
RUN tar -zcvf release.tar.gz ./release/
RUN mkdir outputs
RUN cp release.tar.gz outputs/release.tar.gz
Expand Down
1 change: 0 additions & 1 deletion applications/client/src/store/campaign/presentation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { CampaignViews } from '@redeye/client/types';
import type { UUID } from '@redeye/client/types/uuid';
import { computed } from 'mobx';
import { ExtendedModel, model, modelAction } from 'mobx-keystone';
import type { PresentationCommandGroupModel, PresentationItemModel } from '../graphql';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import type { OptionProps } from '@blueprintjs/core';
import { Divider, FormGroup, HTMLSelect } from '@blueprintjs/core';
import { css } from '@emotion/react';
import { DialogEx, ErrorFallback } from '@redeye/client/components';
import { DialogEx, ErrorFallback, createState } from '@redeye/client/components';
import { RedEyeDbUploadForm } from '@redeye/client/views';
import { CoreTokens, ExternalLink, Header, Txt } from '@redeye/ui-styles';
import { observer } from 'mobx-react-lite';
import type { ComponentProps } from 'react';
import { useMemo, useState } from 'react';
import { ErrorBoundary } from 'react-error-boundary';
import type { ParserInfoModel } from '../../../store';
import { useStore } from '../../../store';
Expand All @@ -21,41 +20,38 @@ const SOURCE_UNSET = '';

export const NewCampaignDialog = observer<NewCampaignDialogProps>(({ ...props }) => {
const store = useStore();
const [currentUploadOptionValue, setCurrentUploadOptionValue] = useState(SOURCE_UNSET);
const state = createState({
currentUploadOptionValue: SOURCE_UNSET as string,
get uploadOptions() {
const options: (OptionProps & {
parserInfo?: ParserInfoModel;
})[] = [
{
label: 'Select Source',
value: SOURCE_UNSET,
disabled: true,
},
];

const uploadOptions = useMemo(() => {
const options: (OptionProps & {
parserInfo?: ParserInfoModel;
})[] = [
{
label: 'Select Source',
value: SOURCE_UNSET,
disabled: true,
},
];

options.push(
...Array.from(store.graphqlStore.parserInfos.values())
.sort((a) => (a.name.includes('Cobalt') ? -1 : 1))
.map((parserInfo) => ({
options.push(
...Array.from(store.graphqlStore.parserInfos.values(), (parserInfo) => ({
label: parserInfo?.uploadForm?.tabTitle,
value: parserInfo.id,
parserInfo,
}))
);

options.push({
label: '.redeye file',
value: 'redeye-file',
});
})).sort((a) => (a.parserInfo.name.toLowerCase().includes('cobalt') ? -1 : 1))
);

return options;
}, [store.graphqlStore.parserInfos.values()]);
options.push({
label: '.redeye file',
value: 'redeye-file',
});

const selectedUploadOption = useMemo(
() => uploadOptions.find((option) => option.value === currentUploadOptionValue),
[uploadOptions, currentUploadOptionValue]
);
return options;
},
get selectedUploadOption() {
return this.uploadOptions.find((option) => option.value === this.currentUploadOptionValue);
},
});

return (
<DialogEx
Expand All @@ -73,24 +69,24 @@ export const NewCampaignDialog = observer<NewCampaignDialogProps>(({ ...props })
<FormGroup css={{ padding: '1rem 1.5rem 1.5rem 1.5rem', margin: 0 }} label="Source">
<HTMLSelect
cy-test="create-new-camp" // <- was {`create-new-camp-${parserInfo.id}`}
value={currentUploadOptionValue}
css={!currentUploadOptionValue && htmlSelectPlaceholderStyle}
options={uploadOptions}
onChange={(e) => setCurrentUploadOptionValue(e.target.value)}
value={state.currentUploadOptionValue}
css={!state.currentUploadOptionValue && htmlSelectPlaceholderStyle}
options={state.uploadOptions}
onChange={(e) => state.update('currentUploadOptionValue', e.target.value)}
fill
large
/>
</FormGroup>
<Divider css={{ margin: '0 1.5rem' }} />
{currentUploadOptionValue === SOURCE_UNSET ? (
{state.currentUploadOptionValue === SOURCE_UNSET ? (
<div css={{ padding: '1.5rem' }}>
<Txt italic muted>
Select an import source to continue
</Txt>
</div>
) : selectedUploadOption?.parserInfo == null ? (
) : state.selectedUploadOption?.parserInfo == null ? (
<RedEyeDbUploadForm onClose={props.onClose} />
) : !selectedUploadOption?.parserInfo?.uploadForm?.enabledInBlueTeam && store.appMeta.blueTeam ? (
) : !state.selectedUploadOption?.parserInfo?.uploadForm?.enabledInBlueTeam && store.appMeta.blueTeam ? (
<div css={{ padding: '1.5rem' }}>
<Txt cy-test="bt-warning" running>
This upload source is not available in BlueTeam mode.
Expand All @@ -101,7 +97,7 @@ export const NewCampaignDialog = observer<NewCampaignDialogProps>(({ ...props })
</Txt>
</div>
) : (
<ParserUploadForm parserInfo={selectedUploadOption?.parserInfo} onClose={props.onClose} />
<ParserUploadForm parserInfo={state.selectedUploadOption?.parserInfo} onClose={props.onClose} />
)}
</div>
</ErrorBoundary>
Expand Down
12 changes: 9 additions & 3 deletions applications/server/src/store/presentation-resolvers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { EntityManager } from '@mikro-orm/core';
import { Arg, Authorized, Ctx, Field, InputType, ObjectType, Query, Resolver, registerEnumType } from 'type-graphql';
import { CommandGroup, Link, Server, Tag } from '@redeye/models';
import { CommandGroup, GenerationType, Link, Server, Tag } from '@redeye/models';
import { beaconHidden } from './utils/hidden-entities-helper';
import { connectToProjectEmOrFail } from './utils/project-db';
import type { GraphQLContext } from '../types';
Expand Down Expand Up @@ -304,7 +304,10 @@ export class PresentationResolvers {
// procedural comments
const proceduralComments = await em.find(
CommandGroup,
{ annotations: { generation: 'PROCEDURAL' }, ...(!hidden ? { commands: { ...beaconHidden(hidden) } } : {}) },
{
annotations: { generation: GenerationType.PROCEDURAL },
...(!hidden ? { commands: { ...beaconHidden(hidden) } } : {}),
},
{
populate: ['commands', 'annotations'],
orderBy,
Expand Down Expand Up @@ -336,7 +339,10 @@ export class PresentationResolvers {
let commandsByUser: PresentationItem[] = [];
const manualComments = await em.find(
CommandGroup,
{ annotations: { generation: 'MANUAL' }, ...(!hidden ? { commands: { ...beaconHidden(hidden) } } : {}) },
{
annotations: { generation: GenerationType.MANUAL },
...(!hidden ? { commands: { ...beaconHidden(hidden) } } : {}),
},
{
populate: ['commands', 'annotations'],
orderBy,
Expand Down
12 changes: 12 additions & 0 deletions create-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
platforms=(mac linux windows)
parsers=(sliver brute-ratel cobalt-strike)

for platform in "${platforms[@]}"; do
echo "Creating server release for $platform"
pkg applications/server/package.json -t node18-$platform-x64 -o release/RedEye-$platform/RedEye
for parser in "${parsers[@]}"; do
echo "Creating $parser release for $platform"
pkg parsers/$parser-parser/package.json -t node18-$platform-x64 -o release/RedEye-$platform/parsers/$parser-parser
done
done

26 changes: 16 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "redeye",
"productName": "RedEye",
"version": "0.9.3",
"version": "0.9.4",
"private": true,
"workspaces": [
"applications/**",
Expand Down Expand Up @@ -35,10 +35,10 @@
"cy:open": "yarn moon run @redeye/e2e:open-cy",
"cy:open-blue": "yarn moon run @redeye/e2e:open-cy-blue",
"start:blue": "SERVER_BLUE_TEAM=true yarn run start:dev",
"release:all": "yarn moon run server:release-all && yarn moon run cobalt-strike-parser:release-all && yarn moon run brute-ratel-parser:release-all",
"release:mac": "yarn moon run server:release-mac && yarn moon run cobalt-strike-parser:release-mac && yarn moon run brute-ratel-parser:release-mac",
"release:linux": "yarn moon run server:release-linux && yarn moon run cobalt-strike-parser:release-linux && yarn moon run brute-ratel-parser:release-linux",
"release:windows": "yarn moon run server:release-windows && yarn moon run cobalt-strike-parser:release-windows && yarn moon run brute-ratel-parser:release-windows"
"release:all": "yarn node ./scripts/create-release.mjs",
"release:mac": "yarn node ./scripts/create-release.mjs --os mac",
"release:linux": "yarn node ./scripts/create-release.mjs --os linux",
"release:windows": "yarn node ./scripts/create-release.mjs --os windows"
},
"dependencies": {
"@apollo/server": "^4.7.0",
Expand All @@ -49,8 +49,8 @@
"@emotion/react": "^11.4.0",
"@emotion/styled": "^11.3.0",
"@fontsource/redacted-script": "^4.5.13",
"@mikro-orm/better-sqlite": "5.6.16",
"@mikro-orm/core": "5.6.16",
"@mikro-orm/better-sqlite": "5.8.4",
"@mikro-orm/core": "5.8.4",
"@openfonts/ibm-plex-mono_all": "^1.44.2",
"@openfonts/ibm-plex-sans_all": "^1.44.2",
"@tanstack/react-query": "^4.1.3",
Expand Down Expand Up @@ -109,9 +109,9 @@
"@babel/plugin-proposal-decorators": "^7.20.13",
"@changesets/cli": "^2.22.0",
"@emotion/babel-plugin": "^11.10.0",
"@mikro-orm/entity-generator": "5.6.16",
"@mikro-orm/migrations": "5.6.16",
"@mikro-orm/seeder": "5.6.16",
"@mikro-orm/entity-generator": "5.8.4",
"@mikro-orm/migrations": "5.8.4",
"@mikro-orm/seeder": "5.8.4",
"@moonrepo/cli": "1.9.2",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
Expand Down Expand Up @@ -212,7 +212,13 @@
"vite-plugin-dts": "^2.3.0",
"vite-tsconfig-paths": "^4.2.0"
},
"overrides": {
"pkg": {
"pkg-fetch": "^3.5.2"
}
},
"resolutions": {
"pkg-fetch": "^3.5.2",
"@moonrepo/core-linux-arm64-gnu": "1.9.2",
"@moonrepo/core-linux-arm64-musl": "1.9.2",
"@moonrepo/core-linux-x64-gnu": "1.9.2",
Expand Down
63 changes: 51 additions & 12 deletions scripts/create-release.mjs
Original file line number Diff line number Diff line change
@@ -1,23 +1,57 @@
import { resolve, join } from 'node:path';
import { resolve } from 'node:path';
import { readdir } from 'node:fs/promises';
import childProc from 'node:child_process';
import { fileURLToPath } from 'node:url';
import { promisify } from 'node:util';
import { parseArgs } from 'node:util';
import {exec as pkgExec} from 'pkg'

const exec = promisify(childProc.exec);
const {
values: {
/** @type {string} */
nodeVersion,
/** @type {['all'] | ('mac' | 'linux' | 'windows' | 'mac-arm')[]} */
os
},
} = parseArgs({
options: {
nodeVersion: {
type: "string",
short: "n",
default: "18.15.0",
},
os: {
type: "string",
multiple: true,
default: ["all"],
short: "o",
},
},
});

const NODE_VER = 'node18';

const NODE_VER = nodeVersion;
const __dirname = fileURLToPath(new URL('.', import.meta.url));

const rootDir = resolve(__dirname, '..');
const releaseDir = resolve(rootDir, 'release');


const OS_ARCH = {
mac: 'macos-x64',
linux: 'linux-x64',
windows: 'win-x64',
'mac-arm': 'macos-arm64',
mac: {
platform: 'macos',
arch: 'x64',
},
linux: {
platform: 'linux',
arch: 'x64',
},
windows: {
platform: 'windows',
arch: 'x64',
},
// 'mac-arm': {
// platform: 'macos',
// arch: 'arm64',
// },
};

const PARSERS = [];
Expand All @@ -30,11 +64,16 @@ const PROJECTS = [
{ path: 'applications/server/package.json', out: 'RedEye' },
...PARSERS.map((parser) => ({ path: `parsers/${parser}`, out: `parsers/${parser}` })),
];

const isAllOS = os.includes('all');
for (const [OS, PKG_KEY] of Object.entries(OS_ARCH)) {
if (!isAllOS && !os.includes(OS)) {
continue;
}
console.log('Building for: ', OS)
for (const project of PROJECTS) {
await exec(
`yarn pkg ${project.path} -t ${NODE_VER}-${PKG_KEY} -o ${resolve(releaseDir, `RedEye-${OS}`, project.out)}`
console.log('\tBuilding: ', project.path)
await pkgExec(
[project.path, '-t', `node${NODE_VER}-${PKG_KEY.platform}-${PKG_KEY.arch}`, '-o', resolve(releaseDir, `RedEye-${OS}`, project.out)]
);
}
}
Loading

0 comments on commit 5440f9b

Please sign in to comment.