MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / generate_database_security_report

Function generate_database_security_report

web/pgadmin/llm/__init__.py:1302–1360  ·  view source on GitHub ↗

Generate a security report for the specified database. Uses the multi-stage pipeline to analyze database security.

(sid, did)

Source from the content-addressed store, hash-verified

1300)
1301@pga_login_required
1302def generate_database_security_report(sid, did):
1303 """
1304 Generate a security report for the specified database.
1305 Uses the multi-stage pipeline to analyze database security.
1306 """
1307 from pgadmin.llm.utils import is_llm_enabled
1308 from pgadmin.llm.reports.generator import generate_report_sync
1309 from pgadmin.utils.driver import get_driver
1310
1311 # Check if LLM is configured
1312 if not is_llm_enabled():
1313 return make_json_response(
1314 success=0,
1315 errormsg=gettext(
1316 'LLM is not configured. Please configure an LLM provider '
1317 'in Preferences > AI.'
1318 )
1319 )
1320
1321 # Get database connection
1322 try:
1323 driver = get_driver(config.PG_DEFAULT_DRIVER)
1324 manager = driver.connection_manager(sid)
1325 conn = manager.connection(did=did)
1326
1327 if not conn.connected():
1328 return make_json_response(
1329 success=0,
1330 errormsg=gettext('Database is not connected.')
1331 )
1332
1333 # Generate report using pipeline
1334 context = {
1335 'database_name': conn.db
1336 }
1337 success, result = generate_report_sync(
1338 report_type='security',
1339 scope='database',
1340 conn=conn,
1341 manager=manager,
1342 context=context
1343 )
1344
1345 if success:
1346 return make_json_response(
1347 success=1,
1348 data={'report': result}
1349 )
1350 else:
1351 return make_json_response(
1352 success=0,
1353 errormsg=result
1354 )
1355
1356 except Exception as e:
1357 return make_json_response(
1358 success=0,
1359 errormsg=gettext('Failed to generate report: ') + str(e)

Callers

nothing calls this directly

Calls 8

is_llm_enabledFunction · 0.90
make_json_responseFunction · 0.90
get_driverFunction · 0.90
generate_report_syncFunction · 0.90
gettextFunction · 0.85
connection_managerMethod · 0.80
connectionMethod · 0.80
connectedMethod · 0.45

Tested by

no test coverage detected