Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /panda-server/pandaserver/asyncprocess/db_read/tables.py was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 """
0002 Tables the async db_read requests may read.
0003 
0004 This list is the allowlist itself: a table that is not here cannot be read, whatever the
0005 request says, so it is meant to be reviewed by hand whenever it changes. The first list
0006 takes the tables the code reads most often, counted over the places in the code that read
0007 the database, leaving out users (it holds DNs and mail addresses); filesTable_ARCH and
0008 CONFIG were added for the coverage they bring. Secrets and proxykey are never to be listed.
0009 
0010 The job and task status logs are not here: GET /v1/job/get_status_history and
0011 GET /v1/task/get_status_history read them.
0012 """
0013 
0014 from dataclasses import dataclass
0015 
0016 from pandaserver.config import panda_config
0017 
0018 
0019 @dataclass(frozen=True)
0020 class AllowedTable:
0021     # name a request uses, matched without regard to case
0022     name: str
0023     # attribute of panda_config holding the schema the table is in
0024     schema_attribute: str
0025 
0026     @property
0027     def owner(self) -> str:
0028         owner: str = getattr(panda_config, self.schema_attribute)
0029         return owner
0030 
0031 
0032 _TABLES = (
0033     AllowedTable("JEDI_Datasets", "schemaJEDI"),
0034     AllowedTable("JEDI_Tasks", "schemaJEDI"),
0035     AllowedTable("jobsActive4", "schemaPANDA"),
0036     AllowedTable("JEDI_Dataset_Contents", "schemaJEDI"),
0037     AllowedTable("filesTable4", "schemaPANDA"),
0038     AllowedTable("jobsDefined4", "schemaPANDA"),
0039     AllowedTable("JEDI_AUX_Status_MinTaskID", "schemaJEDI"),
0040     AllowedTable("JEDI_Events", "schemaJEDI"),
0041     AllowedTable("jobsArchived4", "schemaPANDA"),
0042     AllowedTable("SCHEDCONFIG_JSON", "schemaPANDA"),
0043     AllowedTable("jobsArchived", "schemaPANDAARCH"),
0044     AllowedTable("T_TASK", "schemaDEFT"),
0045     AllowedTable("JEDI_Work_Queue", "schemaJEDI"),
0046     AllowedTable("JOBS_SHARE_STATS", "schemaPANDA"),
0047     AllowedTable("SiteData", "schemaMETA"),
0048     AllowedTable("data_carousel_requests", "schemaJEDI"),
0049     AllowedTable("jobParamsTable", "schemaPANDA"),
0050     AllowedTable("Datasets", "schemaPANDA"),
0051     AllowedTable("data_carousel_relations", "schemaJEDI"),
0052     AllowedTable("filesTable_ARCH", "schemaPANDAARCH"),
0053     AllowedTable("CONFIG", "schemaPANDA"),
0054 )
0055 
0056 ALLOWED_TABLES: dict[str, AllowedTable] = {table.name.lower(): table for table in _TABLES}
0057 
0058 
0059 def get_allowed_table(name: str) -> AllowedTable | None:
0060     """
0061     Get a table of the allowlist.
0062 
0063     Args:
0064         name(str): the name a request gives, in any case
0065 
0066     Returns:
0067         AllowedTable or None: the table, or None when it is not allowed
0068     """
0069     return ALLOWED_TABLES.get(name.lower())