From 3779fe3263efc456950a198885e444f3920c4aa3 Mon Sep 17 00:00:00 2001 From: Alec Blance <17378596+AlecBlance@users.noreply.github.com> Date: Sun, 20 Oct 2024 12:16:21 +0800 Subject: [PATCH] feat: :sparkles: referrer / origin website of s3 buckets --- src/components/Bucket.tsx | 7 ++++++- src/lib/recorder.ts | 8 ++++---- src/types/index.ts | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/components/Bucket.tsx b/src/components/Bucket.tsx index 2169ef5..bc985ad 100644 --- a/src/components/Bucket.tsx +++ b/src/components/Bucket.tsx @@ -93,7 +93,12 @@ const Bucket = ({ {isPermPresent && ( - + + {info.origin && ( +

+ Origin: {info.origin} +

+ )}
{Object.entries(info.permissions).map(([key, value]) => (
diff --git a/src/lib/recorder.ts b/src/lib/recorder.ts index 6c48509..e1155c7 100644 --- a/src/lib/recorder.ts +++ b/src/lib/recorder.ts @@ -17,9 +17,6 @@ const getPerms = ($: cheerio.CheerioAPI, hostname: string) => { const hasListBucket = $("ListBucketResult"); let type = ""; const date = new Date().getTime(); - console.log("Date", date); - console.log("Hostname", hostname); - try { if (!hasUri.length && !hasCode.length && hasListBucket) throw new Error("No permissions"); @@ -99,7 +96,10 @@ export const recordBuckets = async ( storage.set({ buckets: { ...buckets, - [bucketInfo.type]: [bucketInfo.info, ...buckets[bucketInfo.type]], + [bucketInfo.type]: [ + { ...bucketInfo.info, origin: response.initiator }, + ...buckets[bucketInfo.type], + ], }, }); if (bucketInfo.type === "good") addNumber(buckets); diff --git a/src/types/index.ts b/src/types/index.ts index 1f56e99..700ba05 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -4,6 +4,7 @@ export interface IBucketInfo { permissions: Record; date: number; hostname: string; + origin: string; } export type ILastSeen = Record;