Skip to content

Commit

Permalink
[frontend] Add assets platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelHassine committed May 17, 2024
1 parent bc2c822 commit 493de72
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,17 @@ public ExecutionProcess process(@NotNull final Execution execution, @NotNull fin
try {
Endpoint executionEndpoint = this.findAndRegisterAssetForExecution(injection.getInjection().getInject(), asset);
if (executionEndpoint != null) {
this.calderaService.exploit(obfuscator, executionEndpoint.getExternalReference(), contract);
ExploitResult exploitResult = this.calderaService.exploitResult(executionEndpoint.getExternalReference(), contract);
asyncIds.add(exploitResult.getLinkId());
execution.addTrace(traceInfo(EXECUTION_TYPE_COMMAND, exploitResult.getCommand()));
// Compute expectations
boolean isInGroup = assets.get(executionEndpoint.getParent());
computeExpectationsForAsset(expectations, content, executionEndpoint.getParent(), isInGroup);
String result = this.calderaService.exploit(obfuscator, executionEndpoint.getExternalReference(), contract);
if (result.contains("complete")) {
ExploitResult exploitResult = this.calderaService.exploitResult(executionEndpoint.getExternalReference(), contract);
asyncIds.add(exploitResult.getLinkId());
execution.addTrace(traceInfo(EXECUTION_TYPE_COMMAND, exploitResult.getCommand()));
// Compute expectations
boolean isInGroup = assets.get(executionEndpoint.getParent());
computeExpectationsForAsset(expectations, content, executionEndpoint.getParent(), isInGroup);
} else {
execution.addTrace(traceError("Caldera failed to execute ability on asset " + asset.getName() + " (" + result + ")"));
}
} else {
execution.addTrace(traceError("Caldera failed to execute the ability because execution endpoint was not found for endpoint " + asset.getName()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public Result results(@NotBlank final String linkId) {

private final static String EXPLOIT_URI = "/exploit";

public void exploit(
public String exploit(
@NotBlank final String obfuscator,
@NotBlank final String paw,
@NotBlank final String abilityId) {
Expand All @@ -165,11 +165,10 @@ public void exploit(
body.put("obfuscator", obfuscator);
body.put("paw", paw);
body.put("ability_id", abilityId);
String result = this.post(
this.config.getPluginAccessApiUrl() + EXPLOIT_URI,
body
);
assert result.contains("complete"); // the exploit is well taken into account
return this.post(
this.config.getPluginAccessApiUrl() + EXPLOIT_URI,
body
);
} catch (ClientProtocolException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public List<Ability> abilities() {
return this.client.abilities();
}

public void exploit(
public String exploit(
@NotBlank final String obfuscator,
@NotBlank final String paw,
@NotBlank final String abilityId) {
this.client.exploit(obfuscator, paw, abilityId);
return this.client.exploit(obfuscator, paw, abilityId);
}

public List<Obfuscator> obfuscators() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ private void updateEndpoint(@NotNull final Endpoint external, @NotNull final Lis
matchingExistingEndpoint.setName(external.getName());
matchingExistingEndpoint.setIps(external.getIps());
matchingExistingEndpoint.setHostname(external.getHostname());
matchingExistingEndpoint.setPlatform(external.getPlatform());
matchingExistingEndpoint.setExecutor(this.executor);
if ((now().toEpochMilli() - matchingExistingEndpoint.getClearedAt().toEpochMilli()) > CLEAR_TTL) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ private void updateEndpoint(@NotNull final Endpoint external, @NotNull final Lis
matchingExistingEndpoint.setIps(external.getIps());
matchingExistingEndpoint.setHostname(external.getHostname());
matchingExistingEndpoint.setExternalReference(external.getExternalReference());
matchingExistingEndpoint.setPlatform(external.getPlatform());
matchingExistingEndpoint.setExecutor(this.executor);
if ((now().toEpochMilli() - matchingExistingEndpoint.getClearedAt().toEpochMilli()) > CLEAR_TTL) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
Switch,
Tooltip,
} from '@mui/material';
import { ComputerOutlined } from '@mui/icons-material';
import { DevicesOtherOutlined } from '@mui/icons-material';
import * as R from 'ramda';
import { makeStyles } from '@mui/styles';
import Transition from '../../../../components/common/Transition';
Expand All @@ -32,6 +32,7 @@ import type { EndpointHelper } from '../../../../actions/assets/asset-helper';
import useDataLoader from '../../../../utils/hooks/useDataLoader';
import { fetchEndpoints } from '../../../../actions/assets/endpoint-actions';
import useSearchAnFilter from '../../../../utils/SortingFiltering';
import PlatformIcon from '../../../../components/PlatformIcon';

const useStyles = makeStyles(() => ({
box: {
Expand All @@ -43,6 +44,13 @@ const useStyles = makeStyles(() => ({
chip: {
margin: '0 10px 10px 0',
},
bodyItem: {
fontSize: 13,
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
paddingRight: 10,
},
}));

interface Props {
Expand Down Expand Up @@ -163,13 +171,23 @@ const EndpointsDialogAdding: FunctionComponent<Props> = ({
onClick={() => addEndpoint(endpoint.asset_id)}
>
<ListItemIcon>
<ComputerOutlined color="primary" />
<DevicesOtherOutlined color="primary"/>
</ListItemIcon>
<ListItemText
primary={endpoint.asset_name}
secondary={endpoint.asset_description}
primary={
<div style={{ display: 'flex', alignItems: 'center' }}>
<div className={classes.bodyItem} style={{ width: '50%' }}>
{endpoint.asset_name}
</div>
<div className={classes.bodyItem} style={{ width: '25%' }}>
<PlatformIcon platform={endpoint.endpoint_platform} width={20} marginRight={10} /> {endpoint.endpoint_platform}
</div>
<div className={classes.bodyItem} style={{ width: '25%' }}>
<ItemTags variant="list" tags={endpoint.asset_tags} />
</div>
</div>
}
/>
<ItemTags variant="list" tags={endpoint.asset_tags} />
</ListItemButton>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { DevicesOtherOutlined } from '@mui/icons-material';
import { makeStyles } from '@mui/styles';
import type { EndpointStore } from './Endpoint';
import ItemTags from '../../../../components/ItemTags';
import PlatformIcon from '../../../../components/PlatformIcon';

const useStyles = makeStyles(() => ({
item: {
Expand All @@ -29,11 +30,16 @@ const inlineStyles: Record<string, CSSProperties> = {
asset_name: {
width: '40%',
},
asset_platform: {
width: '20%',
display: 'flex',
alignItems: 'center',
},
asset_tags: {
width: '40%',
width: '25%',
},
asset_type: {
width: '20%',
width: '10%',
},
};

Expand Down Expand Up @@ -81,6 +87,12 @@ const EndpointsList: FunctionComponent<Props> = ({
>
{endpoint.asset_name}
</div>
<div
className={classes.bodyItem}
style={inlineStyles.asset_platform}
>
<PlatformIcon platform={endpoint.endpoint_platform} width={20} marginRight={10} /> {endpoint.endpoint_platform}
</div>
<div
className={classes.bodyItem}
style={inlineStyles.asset_tags}
Expand All @@ -94,7 +106,7 @@ const EndpointsList: FunctionComponent<Props> = ({
<Chip
variant="outlined"
className={classes.typeChip}
label={endpoint.type}
label={endpoint.asset_type}
/>
</div>
</>
Expand Down

0 comments on commit 493de72

Please sign in to comment.