Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

Commit

Permalink
Add comment explaining the 32 character limit on IPs and fix by_week …
Browse files Browse the repository at this point in the history
…docstring
  • Loading branch information
aloftus23 committed Nov 2, 2022
1 parent 6570646 commit 241889f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/pe_reports/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, trending_start_date, start_date, end_date, org_uid):
)

def by_week(self):
"""Return number of credentials by day."""
"""Return number of credentials by week."""
df = self.creds_by_day
idx = pd.date_range(self.trending_start_date, self.end_date)
df = df.set_index("mod_date").reindex(idx).fillna(0.0).rename_axis("added_date")
Expand Down Expand Up @@ -217,9 +217,11 @@ def insecure_protocols(self):
.agg(lambda x: " ".join(set(x)))
.reset_index()
)
# Limit the IP column to 32 characters so the table isn't too big.
# 30 characters is the max length of 2 IPs, plus the 2 spaces.
if len(risky_assets.index) > 0:
risky_assets["ip"] = risky_assets["ip"].str[:30]
risky_assets.loc[risky_assets["ip"].str.len() == 30, "ip"] = (
risky_assets["ip"] = risky_assets["ip"].str[:32]
risky_assets.loc[risky_assets["ip"].str.len() == 32, "ip"] = (
risky_assets["ip"] + " ..."
)

Expand Down

0 comments on commit 241889f

Please sign in to comment.