Skip to content

Commit 0b73d97

Browse files
committed
Feature added last updated
1 parent 1960cdf commit 0b73d97

1 file changed

Lines changed: 44 additions & 3 deletions

File tree

src/app.py

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,22 @@ def get_secret_manager_client() -> boto3.client:
4242
secret_manager = session.client("secretsmanager", secret_reigon)
4343
return secret_manager
4444

45+
def get_last_modified() -> dict:
46+
47+
client = get_s3_client()
48+
49+
file_names = ["repositories.json", "secret_scanning.json", "dependabot.json"]
50+
formatted_lm = {}
51+
52+
for x in file_names:
53+
response = client.head_object(Bucket=bucket_name, Key=x)
54+
last_modified = response["LastModified"]
55+
file_key =x.split(".")[0]
56+
formatted_lm[file_key]=last_modified.strftime('%Y-%m-%d %H:%M:%S')
57+
58+
59+
return formatted_lm
60+
4561

4662
@st.cache_data
4763
def load_repositories(_s3, load_date: datetime.date) -> pd.DataFrame | str:
@@ -215,6 +231,7 @@ def load_file(filename: str) -> dict:
215231
loading_date = loading_date[:-1] + "0"
216232

217233
s3 = get_s3_client()
234+
last_modified_values = get_last_modified()
218235

219236
df_repositories = load_repositories(s3, loading_date)
220237
total_secret_alerts, oldest_secret_alert, df_secret_scanning = load_secret_scanning(s3, loading_date)
@@ -258,7 +275,15 @@ def load_file(filename: str) -> dict:
258275
# Repository Analysis Section
259276

260277
with repository_tab:
261-
st.header(":blue-background[Repository Analysis]")
278+
rep_last_modified = last_modified_values["repositories"]
279+
colh, colt =st.columns([3,1])
280+
281+
with colh:
282+
st.header(":blue-background[Repository Analysis]")
283+
284+
with colt:
285+
st.write(f"#### Last Updated: {rep_last_modified}")
286+
262287

263288
# Gets the rules from the repository DataFrame
264289
rules = df_repositories.columns.to_list()[4:]
@@ -546,7 +571,15 @@ def load_file(filename: str) -> dict:
546571
# Secret Scanning Analysis Section
547572

548573
with secret_tab:
549-
st.header(":blue-background[Secret Scanning Analysis]")
574+
colh, colt =st.columns([3,1])
575+
secrets_tab = last_modified_values["secret_scanning"]
576+
577+
with colh:
578+
st.header(":blue-background[Secret Scanning Analysis]")
579+
580+
with colt:
581+
st.write(f"#### Last Updated: {secrets_tab}")
582+
550583
st.write("Alerts open for more than 5 days.")
551584

552585
col1, col2, col3, col4 = st.columns(4)
@@ -584,7 +617,15 @@ def load_file(filename: str) -> dict:
584617
# Dependabot Analysis Section
585618

586619
with dependabot_tab:
587-
st.header(":blue-background[Dependabot Analysis]")
620+
colh, colt =st.columns([3,1])
621+
dependabot = last_modified_values["dependabot"]
622+
623+
with colh:
624+
st.header(":blue-background[Dependabot Analysis]")
625+
626+
with colt:
627+
st.write(f"#### Last Updated: {dependabot}")
628+
588629
st.write("Alerts open for more than 5 days (Critical), 15 days (High), 60 days (Medium), 90 days (Low).")
589630

590631
# Data filters

0 commit comments

Comments
 (0)