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

Function generate_schema_security_report

web/pgadmin/llm/__init__.py:1430–1502  ·  view source on GitHub ↗

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

(sid, did, scid)

Source from the content-addressed store, hash-verified

1428)
1429@pga_login_required
1430def generate_schema_security_report(sid, did, scid):
1431 """
1432 Generate a security report for the specified schema.
1433 Uses the multi-stage pipeline to analyze schema security.
1434 """
1435 from pgadmin.llm.utils import is_llm_enabled
1436 from pgadmin.llm.reports.generator import generate_report_sync
1437 from pgadmin.utils.driver import get_driver
1438
1439 # Check if LLM is configured
1440 if not is_llm_enabled():
1441 return make_json_response(
1442 success=0,
1443 errormsg=gettext(
1444 'LLM is not configured. Please configure an LLM provider '
1445 'in Preferences > AI.'
1446 )
1447 )
1448
1449 # Get database connection
1450 try:
1451 driver = get_driver(config.PG_DEFAULT_DRIVER)
1452 manager = driver.connection_manager(sid)
1453 conn = manager.connection(did=did)
1454
1455 if not conn.connected():
1456 return make_json_response(
1457 success=0,
1458 errormsg=gettext('Database is not connected.')
1459 )
1460
1461 # Get schema name from scid
1462 schema_query = (
1463 "SELECT nspname FROM pg_catalog.pg_namespace WHERE oid = %s"
1464 )
1465 status, result = conn.execute_dict(schema_query, [scid])
1466 if not status or not result.get('rows'):
1467 return make_json_response(
1468 success=0,
1469 errormsg=gettext('Schema not found.')
1470 )
1471 schema_name = result['rows'][0]['nspname']
1472
1473 # Generate report using pipeline
1474 context = {
1475 'database_name': conn.db,
1476 'schema_name': schema_name,
1477 'schema_oid': scid
1478 }
1479 success, result = generate_report_sync(
1480 report_type='security',
1481 scope='schema',
1482 conn=conn,
1483 manager=manager,
1484 context=context
1485 )
1486
1487 if success:

Callers

nothing calls this directly

Calls 10

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
execute_dictMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected