Skip to content

Commit

Permalink
add stix ids to object view pages (#584)
Browse files Browse the repository at this point in the history
* add stix ids to object pages

* update to position of stix id

* minor changes

* css updates
  • Loading branch information
adpare authored Jan 21, 2025
1 parent 06fe259 commit 4cea7fe
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 6 deletions.
3 changes: 3 additions & 0 deletions app/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ import { AttackIDPropertyComponent } from "./components/stix/attackid-property/a
import { AttackIDEditComponent } from "./components/stix/attackid-property/attackid-edit/attackid-edit.component";
import { AttackIDViewComponent } from "./components/stix/attackid-property/attackid-view/attackid-view.component";

import { StixIDPropertyComponent } from "./components/stix/stixid-property/stixid-property.component";

import { ListPropertyComponent } from "./components/stix/list-property/list-property.component";
import { ListEditComponent } from "./components/stix/list-property/list-edit/list-edit.component";
import { ListViewComponent } from "./components/stix/list-property/list-view/list-view.component";
Expand Down Expand Up @@ -262,6 +264,7 @@ export function initConfig(appConfigService: AppConfigService) {
AttackIDPropertyComponent,
AttackIDEditComponent,
AttackIDViewComponent,
StixIDPropertyComponent,
ListPropertyComponent,
ListEditComponent,
ListViewComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<mat-icon>content_copy</mat-icon>
</button>
</div>
<span class="labelled-box-label">ID</span>
<span class="labelled-box-label">ATT&CK ID</span>
</div>
<app-attackid-edit *ngIf="config.mode == 'edit'" [config]="config"></app-attackid-edit>
</div>
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { AttackidViewComponent } from './attackid-view.component';
import { AttackIDViewComponent } from './attackid-view.component';

describe('AttackidViewComponent', () => {
let component: AttackidViewComponent;
let fixture: ComponentFixture<AttackidViewComponent>;
let component: AttackIDViewComponent;
let fixture: ComponentFixture<AttackIDViewComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ AttackidViewComponent ]
declarations: [ AttackIDViewComponent ]
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(AttackidViewComponent);
fixture = TestBed.createComponent(AttackIDViewComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
Expand Down
2 changes: 2 additions & 0 deletions app/src/app/components/stix/stixid-property/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# stixid-property
`stixid-property.component` is used for displaying ATT&CK STIX IDs of an object.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<div class="stix-header text-deemphasis">
<div>
{{config.object["stixID"]}}
<button mat-icon-button class="mini-icon-button" [cdkCopyToClipboard]="stixIdLink"
(click)="snackbar.open('STIX ID copied to clipboard', null, {duration: 1000})"
matTooltip="copy STIX ID" aria-label="copy stixID">
<mat-icon>content_copy</mat-icon>
</button>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.stix-header {
display: flex;
align-items: center;
justify-content: center;
font-size: 14px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { StixIDPropertyComponent } from './stixid-property.component';

describe('StixidPropertyComponent', () => {
let component: StixIDPropertyComponent;
let fixture: ComponentFixture<StixIDPropertyComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ StixIDPropertyComponent ]
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(StixIDPropertyComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Component, Input } from '@angular/core';
import { MatSnackBar } from '@angular/material/snack-bar';
import { StixObject } from 'src/app/classes/stix/stix-object';

@Component({
selector: 'app-stixid-property',
templateUrl: './stixid-property.component.html',
styleUrls: ['./stixid-property.component.scss']
})
export class StixIDPropertyComponent {
@Input() public config: StixIDPropertyConfig;
public get stixIdLink(): string { return `${this.config.object["stixID"]}`; }

constructor(public snackbar: MatSnackBar) {
// intentionally left blank
}
}
export interface StixIDPropertyConfig {
/* What is the current mode?
* view: viewing the list property
*/
mode: "view"
/* The object to show the field of
* Note: if mode is diff, pass an array of two objects to diff
*/
object: StixObject | [StixObject, StixObject];
}
5 changes: 5 additions & 0 deletions app/src/app/components/subheading/subheading.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<!-- view stix id -->
<app-stixid-property class="grow-to-row" *ngIf="config.object['stixID']" [config]="{
object: config.object
}"></app-stixid-property>

<div class="section-header">
<div class="app-subheading">
<div class="section-header-section">
Expand Down
22 changes: 22 additions & 0 deletions app/src/style/layouts/extended-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,26 @@
width: 24px !important;
height: 24px !important;
}
}

.mini-icon-button {
@extend .small-icon-button;
width: 20px !important;
height: 20px !important;

& > *[role=img] {
width: 12px;
height: 12px;
font-size: 12px;

svg {
width: 12px;
height: 12px;
}
}

.mat-mdc-button-touch-target {
width: 12px !important;
height: 12px !important;
}
}

0 comments on commit 4cea7fe

Please sign in to comment.