Skip to content
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
6 changes: 3 additions & 3 deletions backend-agent/app/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class SubAttack(db.Model):
class AttackResult(db.Model):
__tablename__ = 'attack_results'
id = db.Column(db.Integer, primary_key=True)
attack_model_id = db.Column(db.Integer, db.ForeignKey('target_models.id'), nullable=False) # noqa: E501
target_model_id = db.Column(db.Integer, db.ForeignKey('target_models.id'), nullable=False) # noqa: E501
attack_id = db.Column(db.Integer, db.ForeignKey('attacks.id'), nullable=False) # noqa: E501
success = db.Column(db.Boolean, nullable=False)
vulnerability_type = db.Column(db.String, nullable=True)
Expand All @@ -44,13 +44,13 @@ class AttackResult(db.Model):
class ModelAttackScore(db.Model):
__tablename__ = 'model_attack_scores'
id = db.Column(db.Integer, primary_key=True)
attack_model_id = db.Column(db.Integer, db.ForeignKey('target_models.id'), nullable=False) # noqa: E501
target_model_id = db.Column(db.Integer, db.ForeignKey('target_models.id'), nullable=False) # noqa: E501
attack_id = db.Column(db.Integer, db.ForeignKey('attacks.id'), nullable=False) # noqa: E501
total_number_of_attack = db.Column(db.Integer, nullable=False)
total_success = db.Column(db.Integer, nullable=False)

__table_args__ = (
db.UniqueConstraint('attack_model_id', 'attack_id', name='uix_model_attack'), # noqa: E501
db.UniqueConstraint('target_model_id', 'attack_id', name='uix_model_attack'), # noqa: E501
)


Expand Down
6 changes: 3 additions & 3 deletions backend-agent/app/db/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def save_to_db(attack_results: AttackResultDB) -> list[AttackResultDB]:

# Add the attack result to inserted_records
db_record = AttackResultDB(
attack_model_id=target_model.id,
target_model_id=target_model.id,
attack_id=attack.id,
success=success,
vulnerability_type=vulnerability_type,
Expand All @@ -63,12 +63,12 @@ def save_to_db(attack_results: AttackResultDB) -> list[AttackResultDB]:
# If model_attack_score does not exist, create it
# otherwise, update the existing record
model_attack_score = ModelAttackScoreDB.query.filter_by(
attack_model_id=target_model.id,
target_model_id=target_model.id,
attack_id=attack.id
).first()
if not model_attack_score:
model_attack_score = ModelAttackScoreDB(
attack_model_id=target_model.id,
target_model_id=target_model.id,
attack_id=attack.id,
total_number_of_attack=details.get('total_attacks', 0),
total_success=details.get('number_successful_attacks', 0)
Expand Down
2 changes: 1 addition & 1 deletion backend-agent/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def get_heatmap():
Attack.name.label('attack_name'),
Attack.weight.label('attack_weight')
)
.join(TargetModel, ModelAttackScore.attack_model_id == TargetModel.id) # noqa: E501
.join(TargetModel, ModelAttackScore.target_model_id == TargetModel.id) # noqa: E501
.join(Attack, ModelAttackScore.attack_id == Attack.id)
)

Expand Down
135 changes: 76 additions & 59 deletions frontend/package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"lint": "ng lint"
"lint": "eslint . --ext .ts,.html"
},
"private": true,
"dependencies": {
Expand All @@ -32,10 +32,10 @@
"devDependencies": {
"@angular-devkit/build-angular": "^19.2.0",
"@angular-eslint/builder": "^19.1.0",
"@angular-eslint/eslint-plugin": "^19.1.0",
"@angular-eslint/eslint-plugin-template": "^19.1.0",
"@angular-eslint/eslint-plugin": "^19.4.0",
"@angular-eslint/eslint-plugin-template": "^19.4.0",
"@angular-eslint/schematics": "^19.1.0",
"@angular-eslint/template-parser": "^19.1.0",
"@angular-eslint/template-parser": "^19.4.0",
"@angular/cli": "^19.2.0",
"@angular/compiler-cli": "^19.2.0",
"@eslint/js": "^9.27.0",
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Component } from '@angular/core';
import {Component} from '@angular/core';
import {RouterOutlet} from '@angular/router';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
standalone: false
imports: [RouterOutlet],
standalone: true,
})
export class AppComponent {
title = 'application';
Expand Down
43 changes: 0 additions & 43 deletions frontend/src/app/app.module.ts

This file was deleted.

24 changes: 14 additions & 10 deletions frontend/src/app/chatzone/chatzone.component.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import {APIResponse, ReportItem} from '../types/API';
import {AfterViewChecked, AfterViewInit, Component, ElementRef, QueryList, ViewChildren} from '@angular/core';
import {ChatItem, Message, ReportCard, VulnerabilityReportCard} from '../types/ChatItem';
import {Status, Step} from '../types/Step';

import {VulnerabilityInfoService} from '../services/vulnerability-information.service';
import {WebSocketService} from '../services/web-socket.service';
import { APIResponse, ReportItem } from '../types/API';
import { AfterViewChecked, AfterViewInit, Component, ElementRef, QueryList, ViewChildren } from '@angular/core';
import { ChatItem, Message, ReportCard, VulnerabilityReportCard } from '../types/ChatItem';
import { Status, Step } from '../types/Step';

import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { MarkdownModule } from 'ngx-markdown';
import { MatProgressBarModule } from '@angular/material/progress-bar';
import { MaterialModule } from '../material.module';
import { VulnerabilityInfoService } from '../services/vulnerability-information.service';
import { WebSocketService } from '../services/web-socket.service';

@Component({
selector: 'app-chatzone',
templateUrl: './chatzone.component.html',
styleUrls: ['./chatzone.component.css'],
standalone: false,
imports: [MaterialModule, MarkdownModule, MatProgressBarModule, FormsModule, CommonModule],
standalone: true,
})
export class ChatzoneComponent implements AfterViewInit, AfterViewChecked {
chatItems: ChatItem[];
Expand All @@ -30,11 +36,9 @@ export class ChatzoneComponent implements AfterViewInit, AfterViewChecked {

this.ws.webSocket$.subscribe({
next: (value: any) => {
// eslint-disable-line @typescript-eslint/no-explicit-any
this.handleWSMessage(value as APIResponse);
},
error: (error: any) => {
// eslint-disable-line @typescript-eslint/no-explicit-any
console.log(error);
if (error?.type != 'close') {
// Close is already handled via the isConnected call
Expand Down
31 changes: 0 additions & 31 deletions frontend/src/app/heatmap/heatmap.component.html
Original file line number Diff line number Diff line change
@@ -1,36 +1,5 @@
<!-- <p>heatmap works!</p> -->
<!-- <mat-card class="mat-elevation-z4">
<h1>STARS Results Heatmap</h1>
</mat-card> -->

<!-- <mat-card class="mat-elevation-z4 title-card"> -->
<div class="card-header">
<!-- <img src="../../assets/favicon.png" alt="STARS Icon" class="header-icon" /> -->
<span class="title">STARS Results Heatmap</span>
</div>
<!-- </mat-card> -->
<!-- <mat-card class="mat-elevation-z4"> -->
<div class="buttons-wrapper">
<div class="padding-top centered-button">
<button mat-raised-button style="width: 282px; height: 56px" (click)="fileInput.click()">Upload risk scores</button>
<input #fileInput type="file" hidden (change)="uploadCSV($event)" accept=".csv" />
<!-- <button mat-raised-button>Set API Key</button> -->
</div>
</div>

<div id="vendorChoice">
<mat-form-field appearance="outline">
<mat-label>Select a Vendor</mat-label>
<!-- <mat-select [(ngModel)]="selectedVendor" (selectionChange)="onVendorChange($event.value)"> -->
<mat-select [(ngModel)]="selectedVendor" (selectionChange)="onVendorChange($event)">
<mat-option value="">All vendors</mat-option>
<mat-option *ngFor="let vendor of vendorsNames" [value]="vendor">{{ vendor }}</mat-option>
</mat-select>
</mat-form-field>
<span id="overview"> overview</span>
</div>
<!-- </mat-card> -->
<!-- <mat-card class="mat-elevation-z4 heatmap-card"> -->
<div id="heatmapChart"></div>
<!-- <div id="heatmapChart"></div> -->

Loading
Loading