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
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ describe('BaseTableComponent', () => {
const mockWrapper = { id: 1, cracked: 100, taskType: 1, hashlist: { hashCount: 100 } } as JTaskWrapper;
component.getCrackedLinkFromWrapper(mockWrapper).subscribe((links) => {
expect(links.length).toBe(1);
expect(links[0].label).toBe('100/100');
expect(links[0].label).toBe('100');
expect(links[0].routerLink).toBe(null);
expect(links[0].tooltip).toBe('Please access the cracked hashes via the row\'s context menu "show subtasks"');
done();
Expand All @@ -146,7 +146,7 @@ describe('BaseTableComponent', () => {
} as JTaskWrapper;
component.getCrackedLinkFromWrapper(mockWrapper).subscribe((links) => {
expect(links.length).toBe(1);
expect(links[0].label).toBe('100/100');
expect(links[0].label).toBe('100');
expect(links[0].routerLink).toEqual(['/hashlists', 'hashes', 'tasks', 1]);
expect(links[0].tooltip).toBe(undefined);
done();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class BaseTableComponent {
const isSupertask = wrapper.taskType === TaskType.SUPERTASK;

const link: HTTableRouterLink = {
label: wrapper.cracked.toLocaleString() + '/' + wrapper.hashlist.hashCount.toLocaleString(),
label: wrapper.cracked.toLocaleString(),
routerLink: isSupertask ? null : ['/hashlists', 'hashes', 'tasks', wrapper.tasks[0].id],
tooltip: isSupertask ? 'Please access the cracked hashes via the row\'s context menu "show subtasks"' : undefined
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { formatUnixTimestamp } from '@src/app/shared/utils/datetime';
export class HashesTableComponent extends BaseTableComponent implements OnInit, OnDestroy {
@Input() id: number;
@Input() dataType: string;
@Input() filterParam: string;

tableColumns: HTTableColumn[] = [];
dataSource: HashesDataSource;
Expand All @@ -37,6 +38,10 @@ export class HashesTableComponent extends BaseTableComponent implements OnInit,
if (this.id) {
this.dataSource.setId(this.id);
this.dataSource.setDataType(this.dataType);

if (this.filterParam) {
this.dataSource.setFilterParam(this.filterParam);
}
}
this.dataSource.loadAll();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { HashlistsDataSource } from '@datasources/hashlists.datasource';

import { HashListFormatLabel } from '@src/app/core/_constants/hashlist.config';
import { FilterType } from '@src/app/core/_models/request-params.model';
import { formatPercentage } from '@src/app/shared/utils/util';

@Component({
selector: 'app-hashlists-table',
Expand Down Expand Up @@ -101,7 +102,7 @@ export class HashlistsTableComponent extends BaseTableComponent implements OnIni
id: HashlistsTableCol.CRACKED,
dataKey: 'cracked',
icon: (hashlist: JHashlist) => this.renderCrackedStatusIcon(hashlist),
render: (hashlist: JHashlist) => this.renderCrackedHashes(hashlist, false),
routerLink: (hashlist: JHashlist) => this.renderCrackedHashesLink(hashlist),
isSortable: true,
export: async (hashlist: JHashlist) => this.renderCrackedHashes(hashlist, true)
},
Expand Down Expand Up @@ -366,4 +367,21 @@ export class HashlistsTableComponent extends BaseTableComponent implements OnIni
}
return of(links);
}

/**
* Show count of cracked hashes its percentage value
* @param hashlist - hashlist object to show count for
* @return observable array containing the link to render
* @private
*/
private renderCrackedHashesLink(hashlist: JHashlist): Observable<HTTableRouterLink[]> {
const links: HTTableRouterLink[] = [];
if (hashlist) {
links.push({
routerLink: ['/hashlists', 'hashes', 'hashlists', hashlist.id + '?cracked'],
label: `${hashlist.cracked} (${formatPercentage(hashlist.cracked, hashlist.hashCount)})`
});
}
return of(links);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ export class TasksTableComponent extends BaseTableComponent implements OnInit, O
dataKey: 'cracked',
routerLink: (wrapper: JTaskWrapper) => this.renderCrackedLinkFromWrapper(wrapper),
isSortable: true,
export: async (wrapper: JTaskWrapper) =>
wrapper.cracked + '/' + wrapper.hashlist.hashCount.toLocaleString() + ''
export: async (wrapper: JTaskWrapper) => wrapper.cracked + ''
},
{
id: TaskTableCol.AGENTS,
Expand Down
9 changes: 9 additions & 0 deletions src/app/core/_datasources/hashes.datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { BaseDataSource } from '@datasources/base.datasource';
export class HashesDataSource extends BaseDataSource<JHash> {
private _id = 0;
private _dataType: string;
private _filterparam: string;

setId(id: number): void {
this._id = id;
Expand All @@ -22,6 +23,10 @@ export class HashesDataSource extends BaseDataSource<JHash> {
this._dataType = type;
}

setFilterParam(filterparam: string): void {
this._filterparam = filterparam;
}

loadAll(query?: Filter): void {
this.loading = true;

Expand Down Expand Up @@ -52,6 +57,10 @@ export class HashesDataSource extends BaseDataSource<JHash> {
params.addFilter({ field: 'chunkId', operator: FilterType.EQUAL, value: this._id });
} else if (this._dataType === 'hashlists') {
params.addFilter({ field: 'hashlistId', operator: FilterType.EQUAL, value: this._id });

if (this._filterparam) {
params.addFilter({ field: 'isCracked', operator: FilterType.EQUAL, value: true });
}
}

const hashes$ = this.service.getAll(SERV.HASHES, params.create());
Expand Down
2 changes: 1 addition & 1 deletion src/app/hashlists/hashes/hashes.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h2 class="h5 mb-4" *ngIf="whichView === 'chunks' || whichView === 'tasks' || wh
</grid-main>
<!-- Hashes -->
<app-table>
<hashes-table [id]="editedIndex" [dataType]="whichView"></hashes-table>
<hashes-table [id]="editedIndex" [dataType]="whichView" [filterParam]="filterParam"></hashes-table>
</app-table>


24 changes: 12 additions & 12 deletions src/app/hashlists/hashes/hashes.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { DataTableDirective } from 'angular-datatables';
import { Subject } from 'rxjs';

import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
Expand Down Expand Up @@ -37,28 +36,23 @@
// Component Properties
editMode = false;
editedIndex: number;
edited: any; // Change to Model

// View type and filter options
whichView: string;
titleName: any;
titleName: string;
filterParam: string;

// Filtering and Display Properties
crackPos: any = true;

Check failure on line 46 in src/app/hashlists/hashes/hashes.component.ts

View workflow job for this annotation

GitHub Actions / Lint & Prettier Check

Unexpected any. Specify a different type
cracked: any;
filtering = '';
filteringDescr = '';
displaying = '';
displayingDescr = '';
matchHashes: any;

// ViewChild reference to the DataTableDirective
@ViewChild(DataTableDirective)
dtElement: DataTableDirective;

dtTrigger: Subject<any> = new Subject<any>();
dtOptions: any = {};

constructor(
private unsubscribeService: UnsubscribeService,
private titleService: AutoTitleService,
Expand Down Expand Up @@ -114,7 +108,7 @@
});
}

getRouterLink(): any[] {
getRouterLink(): (string | number)[] {
switch (this.whichView) {
case 'chunks':
return ['/tasks/show-tasks/', this.editedIndex, 'edit'];
Expand All @@ -138,7 +132,13 @@
*/
loadHashes(): void {
this.route.params.subscribe((params: Params) => {
this.editedIndex = Number(params['id']);
if (params['id'].includes('?')) {
const split = params['id'].split('?');
this.editedIndex = Number(split[0]);
this.filterParam = split[1];
} else {
this.editedIndex = Number(params['id']);
}
});

this.route.data.subscribe((data) => {
Expand All @@ -150,7 +150,7 @@
data: response.data,
included: response.included
});
this.titleName = chunk.id;
this.titleName = String(chunk.id);
});
break;

Expand Down Expand Up @@ -181,7 +181,7 @@
}

// Update query parameters and trigger updates
onQueryp(name: any, type: number) {
onQueryp(name: string, type: number) {
let query = {};
if (type == 0) {
query = { display: name };
Expand Down
Loading