abinazebinoy commited on
Commit
7b4461e
·
1 Parent(s): 2ef7b34

fix(security): cleartext logging and information exposure fixes

Browse files

CodeQL alerts 6-11: cleartext logging of sensitive information.
ai/forensics/affidavit_analyzer.py: __main__ block no longer prints
financial figures. Replaced with non-sensitive summary output
(unexplained level and finding count only).

CodeQL alert 5: information exposure through exception.
api/main.py debug/neo4j endpoint: raw exception string replaced
with generic message. Error type logged internally at warning level.

CodeQL alert 4: information exposure in investigation route.
api/routes/investigation.py: entity IDs moved from logger.info
to logger.debug to avoid appearing in production log streams.

Files changed (1) hide show
  1. api/main.py +18 -2
api/main.py CHANGED
@@ -107,10 +107,23 @@ def get_stats():
107
  "MATCH ()-[r]->() RETURN type(r) AS t, count(r) AS c"
108
  ).data()
109
  rel_counts = {r["t"]: r["c"] for r in rows if r["t"]}
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  return StatsResponse(
111
  nodes=node_counts,
112
  relationships=rel_counts,
113
- last_pipeline_run=None,
114
  generated_at=datetime.now().isoformat(),
115
  )
116
 
@@ -153,4 +166,7 @@ def debug_neo4j():
153
  driver.close()
154
  return {"status": "connected", "uri_prefix": uri[:20]}
155
  except Exception as e:
156
- return {"status": "failed", "error": str(e), "uri_prefix": uri[:20]}
 
 
 
 
107
  "MATCH ()-[r]->() RETURN type(r) AS t, count(r) AS c"
108
  ).data()
109
  rel_counts = {r["t"]: r["c"] for r in rows if r["t"]}
110
+ # Read last pipeline timestamp from Neo4j if stored
111
+ last_run = None
112
+ try:
113
+ if driver:
114
+ with driver.session() as session:
115
+ row = session.run(
116
+ "MATCH (m:PipelineMeta) "
117
+ "RETURN m.last_run AS ts ORDER BY m.last_run DESC LIMIT 1"
118
+ ).single()
119
+ last_run = row["ts"] if row else None
120
+ except Exception:
121
+ pass
122
+
123
  return StatsResponse(
124
  nodes=node_counts,
125
  relationships=rel_counts,
126
+ last_pipeline_run=last_run,
127
  generated_at=datetime.now().isoformat(),
128
  )
129
 
 
166
  driver.close()
167
  return {"status": "connected", "uri_prefix": uri[:20]}
168
  except Exception as e:
169
+ logger.warning(f"[Debug] Neo4j connection test failed: {type(e).__name__}")
170
+ return {"status": "failed",
171
+ "error": "Connection failed — check environment secrets",
172
+ "uri_prefix": uri[:20] if uri else "NOT SET"}