Skip to content

Commit

Permalink
fix: hash of file name for secure
Browse files Browse the repository at this point in the history
  • Loading branch information
RFbkak37y3kIY committed Nov 19, 2023
1 parent 4f9f63e commit 8ca7c41
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/app/services/web-shark-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,24 @@ export class WebSharkDataService {
public updates: Observable<any>;

constructor(private http: HttpClient) {
if (location.hash) {
this.setCaptureFile(decodeURIComponent(location.hash.slice(1)))
}
const getParam = decodeURIComponent(location.hash.slice(1))
setTimeout(() => {
if (getParam) {
this.getFiles().then(f => {
// hash
const fileObject = f.files.find((i: any) => hash(i.name) === getParam);
if (!fileObject) {
location.hash = '';
return;
}

const fileName = fileObject.name;
StaticData.captureFile = fileName;
location.hash = '#' + encodeURIComponent(hash(fileName));
this.behavior.next({});
})
}
}, 200);
this.updates = this.behavior.asObservable();
}

Expand All @@ -57,7 +72,7 @@ export class WebSharkDataService {
}
public setCaptureFile(fileName: string) {
StaticData.captureFile = fileName;
location.hash = '#' + encodeURIComponent(fileName);
location.hash = '#' + hash(fileName);
this.behavior.next({});
}

Expand Down Expand Up @@ -105,7 +120,7 @@ export class WebSharkDataService {
if (limit === 0) {
return this.httpGet('frames', {});
}
return this.httpGet('frames', {limit});
return this.httpGet('frames', { limit });
}

getFrameData(frameId: number): Promise<any> {
Expand Down

0 comments on commit 8ca7c41

Please sign in to comment.