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

Function generate_security_report

web/pgadmin/llm/__init__.py:1051–1107  ·  view source on GitHub ↗

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

(sid)

Source from the content-addressed store, hash-verified

1049)
1050@pga_login_required
1051def generate_security_report(sid):
1052 """
1053 Generate a security report for the specified server.
1054 Uses the multi-stage pipeline to analyze server configuration.
1055 """
1056 from pgadmin.llm.utils import is_llm_enabled
1057 from pgadmin.llm.reports.generator import generate_report_sync
1058 from pgadmin.utils.driver import get_driver
1059
1060 # Check if LLM is configured
1061 if not is_llm_enabled():
1062 return make_json_response(
1063 success=0,
1064 errormsg=gettext(
1065 'LLM is not configured. Please configure an LLM provider '
1066 'in Preferences > AI.'
1067 )
1068 )
1069
1070 # Get database connection
1071 try:
1072 driver = get_driver(config.PG_DEFAULT_DRIVER)
1073 manager = driver.connection_manager(sid)
1074 conn = manager.connection()
1075
1076 if not conn.connected():
1077 return make_json_response(
1078 success=0,
1079 errormsg=gettext('Server is not connected.')
1080 )
1081
1082 # Generate report using pipeline
1083 context = {}
1084 success, result = generate_report_sync(
1085 report_type='security',
1086 scope='server',
1087 conn=conn,
1088 manager=manager,
1089 context=context
1090 )
1091
1092 if success:
1093 return make_json_response(
1094 success=1,
1095 data={'report': result}
1096 )
1097 else:
1098 return make_json_response(
1099 success=0,
1100 errormsg=result
1101 )
1102
1103 except Exception as e:
1104 return make_json_response(
1105 success=0,
1106 errormsg=gettext('Failed to generate report: ') + str(e)
1107 )
1108

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