Skip to content

Commit 06abc28

Browse files
committed
enhancement(audit log): skip audit for session keep-alive writes
Added logic to bypass auditing for updates that only modify the lastActiveAt field, reducing unnecessary log entries for session keep-alive pings. This change improves performance and log clarity without compromising security. Update prettier scripts and .gitignore
1 parent f297609 commit 06abc28

3 files changed

Lines changed: 34 additions & 21 deletions

File tree

testplanit/.gitignore

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
22

33
# dependencies
4-
./node_modules
5-
./.pnp
6-
./.pnp.js
7-
./.yarn/install-state.gz
4+
node_modules/
5+
.pnp
6+
.pnp.js
7+
.yarn/install-state.gz
88

99
# testing
10-
./coverage
10+
coverage/
1111

1212
# next.js
1313
**/.next/
14-
./out/
14+
out/
1515

1616
# production
17-
./build
17+
build/
1818
dist/
1919

2020
# misc
21-
./.DS_Store
22-
./*.pem
21+
.DS_Store
22+
*.pem
2323

2424
# debug
25-
./npm-debug.log*
26-
./yarn-debug.log*
27-
./yarn-error.log*
25+
npm-debug.log*
26+
yarn-debug.log*
27+
yarn-error.log*
2828

2929
# local env files
30-
./.env*.local
30+
.env*.local
3131
.env.production
3232
.env.production.*
3333

3434
# vercel
35-
./.vercel
35+
.vercel
3636

3737
# customer-specific docker configurations
3838
docker-compose.*.yml
@@ -43,10 +43,10 @@ nginx.*.conf
4343
!nginx.conf
4444

4545
# typescript
46-
./*.tsbuildinfo
47-
./next-env.d.ts
48-
./.env
49-
./test/reports/*
46+
*.tsbuildinfo
47+
next-env.d.ts
48+
.env
49+
test/reports/*
5050

5151
# next-intl
5252
messages/*.d.json.ts
@@ -59,4 +59,7 @@ public/version.json
5959
e2e/.auth/
6060
e2e/playwright-report/
6161
e2e/test-results/
62-
.env.e2e
62+
.env.e2e
63+
64+
# DB backups
65+
backups/

testplanit/lib/prisma.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,16 @@ function createPrismaClient(errorFormat: "pretty" | "colorless") {
685685
return result;
686686
},
687687
async update({ args, query }: any) {
688+
// Skip audit for session keep-alive writes (throttled lastActiveAt
689+
// pings from the session callback). Auditing these produces a log
690+
// entry every 5 minutes per active user with no security value.
691+
const dataKeys = args.data ? Object.keys(args.data) : [];
692+
const isLastActiveOnly =
693+
dataKeys.length === 1 && dataKeys[0] === "lastActiveAt";
694+
if (isLastActiveOnly) {
695+
return query(args);
696+
}
697+
688698
// Fetch old state for audit diff, especially for role changes
689699
const oldEntity = args.where
690700
? await baseClient.user.findUnique({ where: args.where })

testplanit/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"postinstall": "NODE_OPTIONS='--max-old-space-size=12288' zenstack generate && node scripts/fix-zenstack-symlink.js",
1212
"lint": "eslint . && tsc --noEmit",
1313
"type-check": "tsc --noEmit",
14-
"format": "prettier --write .",
15-
"format:check": "prettier --check .",
14+
"format": "prettier --write --ignore-path .gitignore --ignore-path .prettierignore .",
15+
"format:check": "prettier --check --ignore-path .gitignore --ignore-path .prettierignore .",
1616
"check:modal-pattern": "bash scripts/check-modal-pattern.sh",
1717
"start": "next start",
1818
"test": "vitest --config vitest.config.mts",

0 commit comments

Comments
 (0)