mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-25 10:43:35 +00:00
Compare commits
1 Commits
logs-datab
...
1.15.4-s.8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8a364af6a |
@@ -122,8 +122,6 @@ export function queryAccess(data: Q) {
|
|||||||
actorType: accessAuditLog.actorType,
|
actorType: accessAuditLog.actorType,
|
||||||
actorId: accessAuditLog.actorId,
|
actorId: accessAuditLog.actorId,
|
||||||
resourceId: accessAuditLog.resourceId,
|
resourceId: accessAuditLog.resourceId,
|
||||||
resourceName: resources.name,
|
|
||||||
resourceNiceId: resources.niceId,
|
|
||||||
ip: accessAuditLog.ip,
|
ip: accessAuditLog.ip,
|
||||||
location: accessAuditLog.location,
|
location: accessAuditLog.location,
|
||||||
userAgent: accessAuditLog.userAgent,
|
userAgent: accessAuditLog.userAgent,
|
||||||
@@ -143,7 +141,7 @@ async function enrichWithResourceDetails(logs: Awaited<ReturnType<typeof queryAc
|
|||||||
const resourceIds = logs
|
const resourceIds = logs
|
||||||
.map(log => log.resourceId)
|
.map(log => log.resourceId)
|
||||||
.filter((id): id is number => id !== null && id !== undefined);
|
.filter((id): id is number => id !== null && id !== undefined);
|
||||||
|
|
||||||
if (resourceIds.length === 0) {
|
if (resourceIds.length === 0) {
|
||||||
return logs.map(log => ({ ...log, resourceName: null, resourceNiceId: null }));
|
return logs.map(log => ({ ...log, resourceName: null, resourceNiceId: null }));
|
||||||
}
|
}
|
||||||
@@ -218,9 +216,9 @@ async function queryUniqueFilterAttributes(
|
|||||||
const resourceIds = uniqueResources
|
const resourceIds = uniqueResources
|
||||||
.map(row => row.id)
|
.map(row => row.id)
|
||||||
.filter((id): id is number => id !== null);
|
.filter((id): id is number => id !== null);
|
||||||
|
|
||||||
let resourcesWithNames: Array<{ id: number; name: string | null }> = [];
|
let resourcesWithNames: Array<{ id: number; name: string | null }> = [];
|
||||||
|
|
||||||
if (resourceIds.length > 0) {
|
if (resourceIds.length > 0) {
|
||||||
const resourceDetails = await primaryDb
|
const resourceDetails = await primaryDb
|
||||||
.select({
|
.select({
|
||||||
@@ -229,7 +227,7 @@ async function queryUniqueFilterAttributes(
|
|||||||
})
|
})
|
||||||
.from(resources)
|
.from(resources)
|
||||||
.where(inArray(resources.resourceId, resourceIds));
|
.where(inArray(resources.resourceId, resourceIds));
|
||||||
|
|
||||||
resourcesWithNames = resourceDetails.map(r => ({
|
resourcesWithNames = resourceDetails.map(r => ({
|
||||||
id: r.resourceId,
|
id: r.resourceId,
|
||||||
name: r.name
|
name: r.name
|
||||||
@@ -289,7 +287,7 @@ export async function queryAccessAuditLogs(
|
|||||||
const baseQuery = queryAccess(data);
|
const baseQuery = queryAccess(data);
|
||||||
|
|
||||||
const logsRaw = await baseQuery.limit(data.limit).offset(data.offset);
|
const logsRaw = await baseQuery.limit(data.limit).offset(data.offset);
|
||||||
|
|
||||||
// Enrich with resource details (handles cross-database scenario)
|
// Enrich with resource details (handles cross-database scenario)
|
||||||
const log = await enrichWithResourceDetails(logsRaw);
|
const log = await enrichWithResourceDetails(logsRaw);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user