Compare commits

...
5 Commits
Author SHA1 Message Date
lukaszraczylo f367ce618e fix(scanner): stop trivy scans from updating the database
Each trivy scan updated the vulnerability database when the database was
stale. Six concurrent rescans then downloaded it at the same time. A
download took about 11 seconds alone and 38 seconds under contention.
Five of six trivy processes crashed with SIGBUS, because they read a
database that another process replaced. The other scans hit their timeout.

Scans now run with --skip-db-update. A refresh loop updates the database
every 6 hours (trivy.db_update_interval). Scans hold a read lock and an
update holds the write lock, so an update never replaces the database
under a running scan. A scan that finds no database downloads it once
before it scans.

The grype refresh loop moves to the dbrefresh package, which both scanners
use.
2026-12-01 03:20:49 +00:00
lukaszraczylo e4077066ef fix(scanner): remove scanner temp files after every scan
A scanner binary that its timeout kills cannot remove its own temp files.
A killed trivy left its database download in the temp dir as trivy-<n>
and getter<n>, up to 279 MB for each scan. Concurrent rescans filled the
scanner temp dir, and the disk guard then refused all new scans.

Each scanner run now gets a private dir in the temp dir, and the scanner
binary gets this dir as TMPDIR. The scan removes the dir and its contents
when the scan ends, also after a timeout or an error. Each new scan also
removes abandoned dirs that are older than one hour. These dirs come from
a process that stopped during a scan, or from a removal that failed.
2026-12-01 03:11:51 +00:00
github-actions[bot]andGitHub 8c53c3c741 chore(deps): update dependencies
Automated dependency update. All tests passed.
2026-11-30 03:20:41 +00:00
github-actions[bot]andGitHub d8c4607b60 chore(deps): update dependencies
Automated dependency update. All tests passed.
2026-11-29 03:20:57 +00:00
github-actions[bot]andGitHub f9580a7c23 chore(deps): update dependencies
Automated dependency update. All tests passed.
2026-11-28 03:16:37 +00:00
19 changed files with 804 additions and 302 deletions
+1 -1
View File
@@ -15,7 +15,7 @@
"@fontsource/ibm-plex-mono": "5.3.0",
"@fontsource/ibm-plex-sans": "5.3.0",
"@fortawesome/free-solid-svg-icons": "7.3.1",
"@perfect-design/ui": "0.3.11",
"@perfect-design/ui": "0.4.0",
"axios": "^1.20.0",
"pinia": "^4.0.0",
"vue": "^3.5.26",
+166 -170
View File
@@ -23,8 +23,8 @@ importers:
specifier: 7.3.1
version: 7.3.1
'@perfect-design/ui':
specifier: 0.3.11
version: 0.3.11([email protected](@vue/[email protected])([email protected])([email protected]([email protected])))([email protected])([email protected]([email protected]))
specifier: 0.4.0
version: 0.4.0([email protected](@vue/[email protected])([email protected])([email protected]([email protected])))([email protected])([email protected]([email protected]))
axios:
specifier: ^1.20.0
version: 1.21.1([email protected]([email protected]))([email protected])
@@ -36,20 +36,20 @@ importers:
version: 3.5.46([email protected])
vue-router:
specifier: ^5.3.1
version: 5.5.1(@vue/[email protected]5)([email protected])([email protected](@vue/[email protected])([email protected])([email protected]([email protected])))(rolldown@1.2.18)(vite@8.3.8([email protected])([email protected]))([email protected]([email protected]))
version: 5.5.3(@vue/[email protected]6)([email protected])([email protected](@vue/[email protected])([email protected])([email protected]([email protected])))(rolldown@1.3.4)(vite@8.4.0([email protected])([email protected]))([email protected]([email protected]))
devDependencies:
'@tailwindcss/vite':
specifier: ^4.3.3
version: 4.3.5(vite@8.3.8([email protected])([email protected]))
version: 4.3.5(vite@8.4.0([email protected])([email protected]))
'@testing-library/jest-dom':
specifier: ^8.0.0
version: 8.0.0(@testing-library/[email protected])([email protected].1([email protected])(vite@8.3.8([email protected])([email protected])))
version: 8.0.0(@testing-library/[email protected])([email protected].2([email protected])(vite@8.4.0([email protected])([email protected])))
'@testing-library/vue':
specifier: ^8.1.0
version: 8.1.0(@vue/[email protected])(@vue/[email protected]5)(@vue/[email protected])([email protected]([email protected]))
version: 8.1.0(@vue/[email protected])(@vue/[email protected]6)(@vue/[email protected])([email protected]([email protected]))
'@vitejs/plugin-vue':
specifier: ^6.0.3
version: 6.0.11(vite@8.3.8([email protected])([email protected]))([email protected]([email protected]))
version: 6.0.11(vite@8.4.0([email protected])([email protected]))([email protected]([email protected]))
'@vue/test-utils':
specifier: ^2.4.6
version: 2.6.0(@vue/[email protected])(@vue/[email protected])([email protected]([email protected]))
@@ -64,10 +64,10 @@ importers:
version: 6.0.3
vite:
specifier: ^8.0.0
version: 8.3.8([email protected])([email protected])
version: 8.4.0([email protected])([email protected])
vitest:
specifier: ^5.0.3
version: 5.1.1([email protected])(vite@8.3.8([email protected])([email protected]))
version: 5.1.2([email protected])(vite@8.4.0([email protected])([email protected]))
vue-tsc:
specifier: ^3.2.1
version: 3.3.14([email protected])
@@ -350,102 +350,113 @@ packages:
'@one-ini/[email protected]':
resolution: {integrity: sha512-TUqERXGNTifZ9y2g3wPxQrw3HpHv/02DsW3D90T9x0hhonrL1ZqpSmNrU2XkoIq0fP1N6gZfVQzy2Fw1ZvGBNg==}
'@oxc-project/[email protected]56.0':
resolution: {integrity: sha512-1Duyg48TdJNdyhEB8Xn1L36bT9Pv6GUtlKjHxOys8xkaF/rQq3XJE+bAurSK/AgIz5mGFsb77cn9Pb20+WCScw==}
'@oxc-project/[email protected]0.0':
resolution: {integrity: sha512-gw4k9syEmnckbOgw2A2FU1TBDdX9hfwV9jEn/uio65pguPzwWiXQS3OIJDMEhv9m06tj9XiEe6RoD0YA+LgreA==}
'@perfect-design/ui@0.3.11':
resolution: {integrity: sha512-vu7liBjd6ZndJWio3gt1EHmOVi1VAcPQ/v+8xQRLvrIH9Bd43ZYsgsh+JITpBRmagYyAxPjo1zFU7ma/I6lVmg==}
'@perfect-design/ui@0.4.0':
resolution: {integrity: sha512-iAAW2L6ZckwzHUa72bvQkIQjtYTgVBZ5XhH7FMIRQ0zD99G7F7DMgoD8zwomR1tIxkZETNYFzA3lVU50bG30zQ==}
peerDependencies:
pinia: ^3.0.0 || ^4.0.0
tailwindcss: ^4.1.0
vue: ^3.5.0
'@rolldown/binding-android-arm-eabi@1.2.18':
resolution: {integrity: sha512-ubTG+4KlidvioxjOFdsdEa2F6JVGZb8m2ByJUqQ7fYzUeT1cEn194POcsQ10PKH4p//q0YQn4SB3YpSuzcA1Yg==}
'@rolldown/binding-android-arm-eabi@1.3.4':
resolution: {integrity: sha512-xCW8CkL/ualx/SbYqeG9iK87lJCZGDQ0soE+kaORJ0Bd+pHALyE4qK7BStmEAyYWLEzZ3/biSIpA6/7GDFvzIg==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm]
os: [android]
'@rolldown/binding-android-arm64@1.2.18':
resolution: {integrity: sha512-2Xa1t/JeFGTZn5TbzgPppcCftF8sCVnTNvrIvoSdcZhoFzAuVy1L3xxQUQ4sfWDtwVzg1u6Yi1R3SlJugRNV2Q==}
'@rolldown/binding-android-arm64@1.3.4':
resolution: {integrity: sha512-5lifIO+b/prcM9sx/bkPN4w6UEToEfQ3gjhx0+0neuL+dkYskI792CfAq03T51jc8JFcaYXs2hi3l8RjiH/VWQ==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [android]
'@rolldown/binding-darwin-arm64@1.2.18':
resolution: {integrity: sha512-iUzw9HshVvrWci9gVXjxWS7/M/IcLvNo67vu2c/w9zKBz4hIvPRixdUpIW/iCfhldLaq9ER2hecsI9UY5z0/yA==}
'@rolldown/binding-darwin-arm64@1.3.4':
resolution: {integrity: sha512-RCgxTI4AJQxhVF//BI3ImQOsXTHrF4Eg+f99jBy8WoETA2kSEGFxpnrVmW0leQq/2aBR4R5AC6csmy3rc66e3Q==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [darwin]
'@rolldown/binding-darwin-x64@1.2.18':
resolution: {integrity: sha512-XuDHFzbFEtZl0QGJi92+fmG67tfnp1iZ9VOeDkwasGyTq2VG3/5PnJnvAr+MTzFh/rNScJ3VhN+XpZyyGsN7Jw==}
'@rolldown/binding-darwin-x64@1.3.4':
resolution: {integrity: sha512-zNPJVVPUaDEj+L0lImoK3rFv2b+Z5gNijI6DWu/fcD3/1TfmRXKb9ZyxbSN+2AhlctqjbNzUvCsMa+EBhnEM4Q==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [darwin]
'@rolldown/binding-freebsd-x64@1.2.18':
resolution: {integrity: sha512-MM8opLfsLK15oEXDz6iBc0t3ahu+ew9jsAmha+ovZ33hSwYgqo7YmpRITqFTfW7xA71BLEQ3jJdTsaCmhB1c9w==}
'@rolldown/binding-freebsd-x64@1.3.4':
resolution: {integrity: sha512-upP6g7ZIRy5by1RDQ/EphHIdJ5xK0eUD7sUgfZFWJ49s4XdbYsIvIlAPtrFpayR70Hhf9J22lb4Pm8/9FhrZmg==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [freebsd]
'@rolldown/binding-linux-arm-gnueabihf@1.2.18':
resolution: {integrity: sha512-J6EoCWiy5RnFQzHrKyHXXevZ9lukQfGpnchX/zG/k/WC2nc9O9XyS1JgA8kI9VxMFggMbCPjpv7LcikriXfehw==}
'@rolldown/binding-linux-arm-gnueabihf@1.3.4':
resolution: {integrity: sha512-SAX5C5+poMLCxu8dkPF6h5yst40rkzs+9Y3cbPn2OFSydmHjAEprrGi64zGgnYyPIVZfdGUFqJ2fJbfbnHI+mA==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm]
os: [linux]
'@rolldown/binding-linux-arm64-gnu@1.2.18':
resolution: {integrity: sha512-HIkFuLF7CdDeki+1aCZLLbLq0hk/PHntb+z4/YCTo47JbksTD6jJEELIz92tYROmDmvMrNqUMqBi71BkJLDR+A==}
'@rolldown/binding-linux-arm64-gnu@1.3.4':
resolution: {integrity: sha512-nwHqdlRZS6GWBef3dG5/pMY6RNTBBUjj7s0Da+m6xsFpe7jx6IC46SLZcCu8f46JOfCovZmwnrz51EzGE+7Fyw==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@rolldown/binding-linux-arm64-musl@1.2.18':
resolution: {integrity: sha512-4oqWItLLYt7IceOnElCct8T2ek5p7PmD7LN04TRJRXGo5f3HtKTgGH6PhYRFK4C2ICkq/LMUU0BVPvvlAKhm8g==}
'@rolldown/binding-linux-arm64-musl@1.3.4':
resolution: {integrity: sha512-Gr78X2ur/AgLCkmZgHffk/FerIX8S5zb/eII4bCcvJo0ANzeXhTShahdNbpnY6bpiszIAgIfiuKS9ziziWsamw==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [linux]
libc: [musl]
'@rolldown/binding-linux-ppc64-gnu@1.2.18':
resolution: {integrity: sha512-+AkRly5SrCEgnPhGRfub7pucASYEC2fTsxZg7VCcnozpA2+Wn/gCYy1t7LuJS67/xyJu/7noYBJncDUkbwgw2A==}
'@rolldown/binding-linux-ppc64-gnu@1.3.4':
resolution: {integrity: sha512-o9Wcn8nWrsQasaBRYM4d//FwhlBsTJYWkPVlhlt6FwzpwEoovY4IopRZjk5Fq3+ntRuSDORJjF/nA8sFeF2q6w==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [ppc64]
os: [linux]
libc: [glibc]
'@rolldown/binding-linux-s390x-gnu@1.2.18':
resolution: {integrity: sha512-Ttg1r9vVykMnQrE/GwYO9icKtXiuiMfRe/w74xJkeoVuvhRG+WtT6LEMOf58Yl63yd77lhHzO8Y55R8CC3XALA==}
'@rolldown/binding-linux-s390x-gnu@1.3.4':
resolution: {integrity: sha512-UDWu4jkVcx2kiBKm3Ec//4lVCbeTWj8gmJ9SyLWCdLWtTlyq7fQVeVV/14nXvRtSLErvJ2+yA/Ux5taS31Y17Q==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [s390x]
os: [linux]
libc: [glibc]
'@rolldown/binding-linux-x64-gnu@1.2.18':
resolution: {integrity: sha512-xX1Tt4o5jUMma0vJsXp5eRZA9nOuyigb2dKJMMzZRmzMxLYGE9PaKKSqHPzPvSQgM8ZOEacSTQwDQcwWfh0xmQ==}
'@rolldown/binding-linux-x64-gnu@1.3.4':
resolution: {integrity: sha512-W9mGtTa0w4fWh8RLMNPyaEhhcuqUfO07Q4I1bBc4PDMNg7gQSw0yPQNQ3D0qwbkXwxbyL4YrIzc8n6k1vuFExQ==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [linux]
libc: [glibc]
'@rolldown/binding-linux-x64-musl@1.2.18':
resolution: {integrity: sha512-4VVlGI5K2kociZlW3lSN8VjG3TW5yQIlAcfCdBXMgGjJxZll15Fa4ocRHXHvIVVnwlibCw/NQajJrNDiqqpiiw==}
'@rolldown/binding-linux-x64-musl@1.3.4':
resolution: {integrity: sha512-8B+ofyQZ7/aCmkqnyMonPr5zKLqMVNczhRGFNtdIuItiwNn8iQWJawMq2E58r7bxD1XEbtRRsULY/eCWwZQ01Q==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [linux]
libc: [musl]
'@rolldown/binding-openharmony-arm64@1.2.18':
resolution: {integrity: sha512-PApTsgH1jLYuyy3tSCz9De82Gq5qXwi7vImVZhEzTgX1C4150Cp5M2ZfL3pLvbCvbEHL0oJeC6pd6podtv8Y5w==}
'@rolldown/binding-openharmony-arm64@1.3.4':
resolution: {integrity: sha512-TlD0FSZaC7o2B4NCe9V5N11ugTnhzTM9ksj4sgRLvrKosDzjEkvlsTX3ehkw4ZlPv8AADimZZTvJGEa16pfXug==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [openharmony]
'@rolldown/binding-w[email protected]':
resolution: {integrity: sha512-J2XjWjx/SP+4x0H4r6dz3Vzb5WVkg7re40Do9K7HJ3sK2/xcmZrWwakXlSwaMvOkvruLJCD4CL/3wqsIR/thgg==}
'@rolldown/binding-w[email protected]':
resolution: {integrity: sha512-jwO8P3o53ygo7b5061B7BeaJ1BGv3BKZ6jroFdw/01qWry7Z+qNBlDvulzbTle5s/A0Fc1FRgsTxrke9DvsSbA==}
engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0}
cpu: [wasm32]
'@rolldown/[email protected]':
resolution: {integrity: sha512-8adGMrNtrdzi2WD1ozhYapER59gD8Q/DV6SCKJlyG2HqULPdeQUBvMa33lTsiEYwIqTZUaIU2MmvPp5f1wbtXA==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [win32]
'@rolldown/binding-win32-x64-msvc@1.2.18':
resolution: {integrity: sha512-XwRJxRQvkuEtS0hIIt29QrqPJ+JzMJSNYHJw4ae/mc6uEarfRG1ceyg4HmmWiBdL/YCb6g7N5BLbSvmRJRYZHw==}
'@rolldown/binding-win32-x64-msvc@1.3.4':
resolution: {integrity: sha512-rIMjtESdXJCIoOiUTroQ1Y1rjVDZkuUVRUxs3APX2vNv175D7TDWvzdELiIhzGq9cUNUFat+co+PTmPHPqSREg==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [win32]
@@ -603,8 +614,8 @@ packages:
vite: ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0
vue: ^3.2.25 || ^3.6.0-rc.15
'@vitest/[email protected].1':
resolution: {integrity: sha512-b2OgTB4+3ImWIVafXKazJXwLKwQxUNnix6b3xUvUTMh7RyXlrtzoxfZr8aEz9zkHOMAS4K5lu3TvFWoiVeVTQg==}
'@vitest/[email protected].2':
resolution: {integrity: sha512-UGc97wUIy0Ji2+9GxzHEJiOhiwkaukgE7VYcUNnjpX3sWnwQ8XogmNXX4WyOukxYgKb8Nh2XFa7KId0ZjpmVhQ==}
peerDependencies:
msw: ^2.4.9 || ^3.0.0
vite: ^6.0.0 || ^7.0.0 || ^8.0.0
@@ -614,8 +625,8 @@ packages:
vite:
optional: true
'@vitest/[email protected].1':
resolution: {integrity: sha512-6K8C6alQG1/Yc8/ZI22iJS7JEsxPdVzqtqDq+/xM4Z0mGVykemMVjLhqMy/q6/IHYG3kKD8hKSwRen/ZdyI9vQ==}
'@vitest/[email protected].2':
resolution: {integrity: sha512-PQl0/3+p9GaY71+MHywN6oyHfLhVDD5kcbm7oNRldA2F0ExMU3S8RQdnpteJ9gFAdK5P6KCgE6LqCpUgy57KzA==}
'@volar/[email protected]':
resolution: {integrity: sha512-73fjwEV8wat6aOZ6U/y/hqtE30ocrIWECg67b0txGczOMNw+MffLmvJ5fnFfN9drVUEYZzLdaNo6VAy6G6avMw==}
@@ -651,30 +662,18 @@ packages:
'@vue/[email protected]':
resolution: {integrity: sha512-k34nCytbK8PQ1gR2mGROYOw6Pnv/mumqIdrZ3x2tbyXZDWm7ViKGLTfdB+DRrWqEQsLgGJvn0WN9jBif5zCTLQ==}
'@vue/[email protected]':
resolution: {integrity: sha512-XGHJrM6ufZARAc/w+tyOswStw9tdKiqCKBScI4gGaNxD+aaGu/HQWgKJ+JItjRLPqenQ7iE7G8AJC7T5ew1p+g==}
'@vue/[email protected]':
resolution: {integrity: sha512-yb+N8/mgBcoeqCJPVyJI/D3OphLrSMXnB3ZQUNmRLU/1fsMW4bFfdJWNi9oIj7+EA3ULKKkP7b/VCpcYQYeiuQ==}
'@vue/[email protected]':
resolution: {integrity: sha512-W5AoBFWdw1lQAKiHowkfgFKFab82oSRT6sGsPfw/q1GRjsy/ZJFLHGhJyBRIFN9APLTUduDH9U2JAiPOIyKuYg==}
'@vue/[email protected]':
resolution: {integrity: sha512-LbP2d19GSOYGPmvMBBCVJVlv7TKtjM1Cfeyu3cYia720pknZP+1cLX7H5MVatvruT6MuJhiPuNbQBW/MDn/EwA==}
'@vue/[email protected]':
resolution: {integrity: sha512-Bj3lCSw3DQnDRDxw115XqdLDd0+18Nftlgd8OXSGG+ud74hxJIE17eYrM+VWgQrTMsvJbLh9Hzf2MkwAzru36Q==}
'@vue/[email protected]':
resolution: {integrity: sha512-MKFjb2UX0M/l/jhfzqMLrI8VM4pfvFKG3pqFZkSZFHRLtNld/O4RtUPZFWSwhro/14qP88UQEkWzHxAZAQ0tsw==}
'@vue/[email protected]':
resolution: {integrity: sha512-hjUvMxGh+QIgegwksfp6BRBYleE/a8veZHvTR6sa+o+bM4HU+WnrUZlhN0X+pDcsl8Lhwmbu72xPvLMk3XUwog==}
'@vue/[email protected]':
resolution: {integrity: sha512-RF5sbZOfYz5AK00tOJUn2PwFXR2fS1u2HVzI8D9VF9rGAFxuGBqg2bB1kJ3ZHMprqSltXnT9MZE1IsqjSM8oew==}
'@vue/[email protected]':
resolution: {integrity: sha512-qebChL3aP0m1k+TlSf+fZWvOwAf3flBCi5o+n01ykR3DX4mTIWheFltmoiQ12+z66/4cGeXqbB2P7sPWkGhQNQ==}
@@ -705,9 +704,6 @@ packages:
'@vue/[email protected]':
resolution: {integrity: sha512-H82XLH0DjmSOdbEwO15x3QTo1f5PWEtv237eLpYKc0mqLu+B8hnq16lFWmuBmNurkeiG3wr+oM1FhOll/YVFRg==}
'@vue/[email protected]':
resolution: {integrity: sha512-ue9fgHmVNPlP7iW3+cxoBX/Cnlw53dHlVSw0JKGY6z1lObg8pHoj928M2nzG4/yVsMZ3NaRZ2s2z61uC16NDwQ==}
'@vue/[email protected]':
resolution: {integrity: sha512-P1WePbdzHrcIciWtmY2Im9EFhdakd3rZxYqvalOa3SfoxtF35Q8Uhmj1tKn6bWP4utcOpN8ao6BoJUItq0Uf+g==}
@@ -1315,11 +1311,21 @@ packages:
[email protected]:
resolution: {integrity: sha512-VNTrAak/KhO2i8dqqnqnAHOa3cYBwXEZe9h+D5h/1ZqFSTEFHdM65lR7RoIqq3tBBYavsOXV84NoHXZ0AkPyqQ==}
[email protected]:
resolution: {integrity: sha512-p3QA1y3s9L+FVrdjgtzOtG84A0x8mM7Z/hEjY2VkOsLWyjgsGZmXHNbnAtLjMDX4uDg9oTeGHj8E+siSs9WIfA==}
engines: {node: '>=12'}
[email protected]:
resolution: {integrity: sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==}
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
hasBin: true
[email protected]:
resolution: {integrity: sha512-zHxhzKsIFu3elch3eFw69WEUGc79DFhbc3nD/WEOzWL/pFFLZRW13EHnuO0c+0YjncE5uCaS9ICHxOBXkb6vPw==}
engines: {node: '>=20'}
cpu: [x64, arm64]
os: [win32]
[email protected]:
resolution: {integrity: sha512-df3sBr/6ax9hSGuC3CspvLlbnX8cP5L5nZwXF8cGN8l0zSWR6BvzmQ6jPUKjvo6+/xdpkNvEcucBNUdBeeV13g==}
engines: {node: ^22.22.2 || ^24.15.0 || >=26.0.0}
@@ -1401,6 +1407,10 @@ packages:
resolution: {integrity: sha512-LJlKCCAUFKOuZxipUdYw1NzIITEsPcgyOG9LkvRJvuKj/bRzbuRY0ARXvL0pWGpsZvn8jku+LMep2eU0seHp8g==}
engines: {node: ^10 || ^12 || >=14}
[email protected]:
resolution: {integrity: sha512-P1Qzj0XXZjMda74C7qiVnBG90UKNbyNUAOeQRBW8X63RsIMV57gevRqjnkELdwtZ/S2/uQFksJhmwuN8xShLPw==}
engines: {node: ^10 || ^12 || >=14}
[email protected]:
resolution: {integrity: sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==}
engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0}
@@ -1442,8 +1452,8 @@ packages:
peerDependencies:
vue: '>= 3.4.0'
rolldown@1.2.18:
resolution: {integrity: sha512-C1uuT3UR60SShuCaPQFAAZyefJCWZlAKB02BV3BuPE2Rs4fevRQltEKoFO2tV5W9/eJhU5RieV6vJj3euulfNQ==}
rolldown@1.3.4:
resolution: {integrity: sha512-p2rq4bfBmF0M6yaR8+A89fbkBQynZI2fxUW4G07eq9kpctAkpo7q5BZ4X4Mo4XZ7HHROu33cX9PeopUFN6u+2Q==}
engines: {node: ^20.19.0 || >=22.12.0}
hasBin: true
@@ -1602,8 +1612,8 @@ packages:
webpack:
optional: true
vite@8.3.8:
resolution: {integrity: sha512-LzOn3h9rG/0vhLdXrV4yJ4QFA9eEoqCl+Yx+kGJd7aB9w6nfNgVHKSYwLPZUHrz4ZGa+t+kXjV9itvcHDLQouA==}
vite@8.4.0:
resolution: {integrity: sha512-X2nUJg+9cutlz3hzqyO6p+WTwk9H257DjwAEf9EQYUFrQbDItmetadi9gYmb+l7VDy4r3VXLUnmLTwuPmzejDw==}
engines: {node: ^20.19.0 || >=22.12.0}
hasBin: true
peerDependencies:
@@ -1645,20 +1655,20 @@ packages:
yaml:
optional: true
[email protected].1:
resolution: {integrity: sha512-trVmzUFOSraCZcI3uZIMD5FqBh4atFkC/XuJP/IU7qtyQay0FCs3Ia+0QiQ2JJwGyWG/xrcBoJNel2+O7kEZ0g==}
[email protected].2:
resolution: {integrity: sha512-VIa2wXV208WraXUbzH+dQUrGcFpPuaiRA8HlhXS8R6/sy9cynw6OMqGj8fmAlH1hot7huTCtWUE14+FdXU3eLw==}
engines: {node: ^22.12.0 || ^24.0.0 || >=26.0.0}
hasBin: true
peerDependencies:
'@edge-runtime/vm': '*'
'@opentelemetry/api': ^1.9.0
'@types/node': ^22.0.0 || >=24.0.0
'@vitest/browser-playwright': 5.1.1
'@vitest/browser-preview': 5.1.1
'@vitest/browser-playwright': 5.1.2
'@vitest/browser-preview': 5.1.2
'@vitest/browser-webdriverio': ^5.0.0-beta.5 || >=5.0.0
'@vitest/coverage-istanbul': 5.1.1
'@vitest/coverage-v8': 5.1.1
'@vitest/ui': 5.1.1
'@vitest/coverage-istanbul': 5.1.2
'@vitest/coverage-v8': 5.1.2
'@vitest/ui': 5.1.2
happy-dom: '*'
jsdom: '*'
vite: ^6.4.0 || ^7.0.0 || ^8.0.0
@@ -1705,14 +1715,14 @@ packages:
[email protected]:
resolution: {integrity: sha512-HwCqmgTfLFskQc4P5TRnbduCMyPat2Ezu0elLWOGn0dD/6BKHP15B5bxce6aDi+E4kblPtru8amIBQzu0Di3qQ==}
[email protected].1:
resolution: {integrity: sha512-lUENd/QIhKd2HWACnXID3us0GWBnuOi3BwkTUzce2+4nfM/b3seV5saNURM9+wt48/qUxviotpcm7yFxC0U4qA==}
[email protected].3:
resolution: {integrity: sha512-F3uyE2siuOC8QLxR3YAdqtxTEgLM/+rc0Fvej7/DVo6YTY5RgLBQpm1+fYP26ITjD3Fg5rDWuzBKxIB6rjlt1w==}
peerDependencies:
'@pinia/colada': '>=0.21.2'
'@vue/compiler-sfc': ^3.5.34 || ^4.0.0
'@vue/compiler-sfc': ^3.5.34 || ^3.6.0-0 || ^4.0.0
pinia: ^3.0.4 || ^4.0.2
vite: ^7.3.0 || ^8.0.0
vue: ^3.5.34 || ^4.0.0
vue: ^3.5.34 || ^3.6.0-0 || ^4.0.0
peerDependenciesMeta:
'@pinia/colada':
optional: true
@@ -1965,9 +1975,9 @@ snapshots:
'@one-ini/[email protected]': {}
'@oxc-project/[email protected]56.0': {}
'@oxc-project/[email protected]0.0': {}
'@perfect-design/ui@0.3.11([email protected](@vue/[email protected])([email protected])([email protected]([email protected])))([email protected])([email protected]([email protected]))':
'@perfect-design/ui@0.4.0([email protected](@vue/[email protected])([email protected])([email protected]([email protected])))([email protected])([email protected]([email protected]))':
dependencies:
pinia: 4.1.0(@vue/[email protected])([email protected])([email protected]([email protected]))
reka-ui: 2.11.0([email protected]([email protected]))
@@ -1975,49 +1985,54 @@ snapshots:
tailwindcss: 4.3.5
vue: 3.5.46([email protected])
'@rolldown/binding-android-arm-eabi@1.2.18':
'@rolldown/binding-android-arm-eabi@1.3.4':
optional: true
'@rolldown/binding-android-arm64@1.2.18':
'@rolldown/binding-android-arm64@1.3.4':
optional: true
'@rolldown/binding-darwin-arm64@1.2.18':
'@rolldown/binding-darwin-arm64@1.3.4':
optional: true
'@rolldown/binding-darwin-x64@1.2.18':
'@rolldown/binding-darwin-x64@1.3.4':
optional: true
'@rolldown/binding-freebsd-x64@1.2.18':
'@rolldown/binding-freebsd-x64@1.3.4':
optional: true
'@rolldown/binding-linux-arm-gnueabihf@1.2.18':
'@rolldown/binding-linux-arm-gnueabihf@1.3.4':
optional: true
'@rolldown/binding-linux-arm64-gnu@1.2.18':
'@rolldown/binding-linux-arm64-gnu@1.3.4':
optional: true
'@rolldown/binding-linux-arm64-musl@1.2.18':
'@rolldown/binding-linux-arm64-musl@1.3.4':
optional: true
'@rolldown/binding-linux-ppc64-gnu@1.2.18':
'@rolldown/binding-linux-ppc64-gnu@1.3.4':
optional: true
'@rolldown/binding-linux-s390x-gnu@1.2.18':
'@rolldown/binding-linux-s390x-gnu@1.3.4':
optional: true
'@rolldown/binding-linux-x64-gnu@1.2.18':
'@rolldown/binding-linux-x64-gnu@1.3.4':
optional: true
'@rolldown/binding-linux-x64-musl@1.2.18':
'@rolldown/binding-linux-x64-musl@1.3.4':
optional: true
'@rolldown/binding-openharmony-arm64@1.2.18':
'@rolldown/binding-openharmony-arm64@1.3.4':
optional: true
'@rolldown/binding-w[email protected]':
'@rolldown/binding-w[email protected]':
dependencies:
'@oxc-project/types': 0.160.0
optional: true
'@rolldown/binding-win32-x64-msvc@1.2.18':
'@rolldown/binding-win32-arm64-msvc@1.3.4':
optional: true
'@rolldown/[email protected]':
optional: true
'@rolldown/[email protected]': {}
@@ -2087,12 +2102,12 @@ snapshots:
'@tailwindcss/oxide-win32-arm64-msvc': 4.3.5
'@tailwindcss/oxide-win32-x64-msvc': 4.3.5
'@tailwindcss/[email protected](vite@8.3.8([email protected])([email protected]))':
'@tailwindcss/[email protected](vite@8.4.0([email protected])([email protected]))':
dependencies:
'@tailwindcss/node': 4.3.5
'@tailwindcss/oxide': 4.3.5
tailwindcss: 4.3.5
vite: 8.3.8([email protected])([email protected])
vite: 8.4.0([email protected])([email protected])
'@tanstack/[email protected]': {}
@@ -2123,7 +2138,7 @@ snapshots:
lz-string: 1.5.0
pretty-format: 27.5.1
'@testing-library/[email protected](@testing-library/[email protected])([email protected].1([email protected])(vite@8.3.8([email protected])([email protected])))':
'@testing-library/[email protected](@testing-library/[email protected])([email protected].2([email protected])(vite@8.4.0([email protected])([email protected])))':
dependencies:
'@adobe/css-tools': 4.4.4
'@testing-library/dom': 10.4.2
@@ -2133,16 +2148,16 @@ snapshots:
picocolors: 1.1.1
redent: 3.0.0
optionalDependencies:
vitest: 5.1.1([email protected])(vite@8.3.8([email protected])([email protected]))
vitest: 5.1.2([email protected])(vite@8.4.0([email protected])([email protected]))
'@testing-library/[email protected](@vue/[email protected])(@vue/[email protected]5)(@vue/[email protected])([email protected]([email protected]))':
'@testing-library/[email protected](@vue/[email protected])(@vue/[email protected]6)(@vue/[email protected])([email protected]([email protected]))':
dependencies:
'@babel/runtime': 7.28.4
'@testing-library/dom': 9.3.4
'@vue/test-utils': 2.6.0(@vue/[email protected])(@vue/[email protected])([email protected]([email protected]))
vue: 3.5.46([email protected])
optionalDependencies:
'@vue/compiler-sfc': 3.5.45
'@vue/compiler-sfc': 3.5.46
transitivePeerDependencies:
- '@vue/compiler-dom'
- '@vue/server-renderer'
@@ -2160,22 +2175,22 @@ snapshots:
'@types/[email protected]': {}
'@vitejs/[email protected](vite@8.3.8([email protected])([email protected]))([email protected]([email protected]))':
'@vitejs/[email protected](vite@8.4.0([email protected])([email protected]))([email protected]([email protected]))':
dependencies:
'@rolldown/pluginutils': 1.0.1
vite: 8.3.8([email protected])([email protected])
vite: 8.4.0([email protected])([email protected])
vue: 3.5.46([email protected])
'@vitest/[email protected].1(vite@8.3.8([email protected])([email protected]))':
'@vitest/[email protected].2(vite@8.4.0([email protected])([email protected]))':
dependencies:
'@jridgewell/trace-mapping': 0.3.31
'@vitest/spy': 5.1.1
'@vitest/spy': 5.1.2
estree-walker: 3.0.3
magic-string: 1.4.5
optionalDependencies:
vite: 8.3.8([email protected])([email protected])
vite: 8.4.0([email protected])([email protected])
'@vitest/[email protected].1': {}
'@vitest/[email protected].2': {}
'@volar/[email protected]':
dependencies:
@@ -2203,7 +2218,7 @@ snapshots:
'@vue-macros/[email protected]([email protected]([email protected]))':
dependencies:
'@vue/compiler-sfc': 3.5.45
'@vue/compiler-sfc': 3.5.46
ast-kit: 2.2.0
local-pkg: 1.2.1
magic-string-ast: 1.0.3
@@ -2219,14 +2234,6 @@ snapshots:
estree-walker: 2.0.2
source-map-js: 1.2.2
'@vue/[email protected]':
dependencies:
'@babel/parser': 7.29.13
'@vue/shared': 3.5.45
entities: 7.0.1
estree-walker: 2.0.2
source-map-js: 1.2.2
'@vue/[email protected]':
dependencies:
'@babel/parser': 7.29.13
@@ -2240,28 +2247,11 @@ snapshots:
'@vue/compiler-core': 3.5.44
'@vue/shared': 3.5.44
'@vue/[email protected]':
dependencies:
'@vue/compiler-core': 3.5.45
'@vue/shared': 3.5.45
'@vue/[email protected]':
dependencies:
'@vue/compiler-core': 3.5.46
'@vue/shared': 3.5.46
'@vue/[email protected]':
dependencies:
'@babel/parser': 7.29.13
'@vue/compiler-core': 3.5.45
'@vue/compiler-dom': 3.5.45
'@vue/compiler-ssr': 3.5.45
'@vue/shared': 3.5.45
estree-walker: 2.0.2
magic-string: 0.30.21
postcss: 8.5.32
source-map-js: 1.2.2
'@vue/[email protected]':
dependencies:
'@babel/parser': 7.29.13
@@ -2274,11 +2264,6 @@ snapshots:
postcss: 8.5.32
source-map-js: 1.2.4
'@vue/[email protected]':
dependencies:
'@vue/compiler-dom': 3.5.45
'@vue/shared': 3.5.45
'@vue/[email protected]':
dependencies:
'@vue/compiler-dom': 3.5.46
@@ -2331,8 +2316,6 @@ snapshots:
'@vue/[email protected]': {}
'@vue/[email protected]': {}
'@vue/[email protected]': {}
'@vue/[email protected](@vue/[email protected])(@vue/[email protected])([email protected]([email protected]))':
@@ -2970,8 +2953,13 @@ snapshots:
[email protected]: {}
[email protected]: {}
[email protected]: {}
[email protected]:
optional: true
[email protected]:
dependencies:
abbrev: 5.0.0
@@ -3051,6 +3039,12 @@ snapshots:
picocolors: 1.1.1
source-map-js: 1.2.2
[email protected]:
dependencies:
nanoid: 3.3.20
picocolors: 1.1.1
source-map-js: 1.2.4
[email protected]:
dependencies:
ansi-regex: 5.0.1
@@ -3098,26 +3092,27 @@ snapshots:
ohash: 2.0.11
vue: 3.5.46([email protected])
rolldown@1.2.18:
rolldown@1.3.4:
dependencies:
'@oxc-project/types': 0.156.0
'@oxc-project/types': 0.160.0
'@rolldown/pluginutils': 1.0.1
optionalDependencies:
'@rolldown/binding-android-arm-eabi': 1.2.18
'@rolldown/binding-android-arm64': 1.2.18
'@rolldown/binding-darwin-arm64': 1.2.18
'@rolldown/binding-darwin-x64': 1.2.18
'@rolldown/binding-freebsd-x64': 1.2.18
'@rolldown/binding-linux-arm-gnueabihf': 1.2.18
'@rolldown/binding-linux-arm64-gnu': 1.2.18
'@rolldown/binding-linux-arm64-musl': 1.2.18
'@rolldown/binding-linux-ppc64-gnu': 1.2.18
'@rolldown/binding-linux-s390x-gnu': 1.2.18
'@rolldown/binding-linux-x64-gnu': 1.2.18
'@rolldown/binding-linux-x64-musl': 1.2.18
'@rolldown/binding-openharmony-arm64': 1.2.18
'@rolldown/binding-win32-arm64-msvc': 1.2.18
'@rolldown/binding-win32-x64-msvc': 1.2.18
'@rolldown/binding-android-arm-eabi': 1.3.4
'@rolldown/binding-android-arm64': 1.3.4
'@rolldown/binding-darwin-arm64': 1.3.4
'@rolldown/binding-darwin-x64': 1.3.4
'@rolldown/binding-freebsd-x64': 1.3.4
'@rolldown/binding-linux-arm-gnueabihf': 1.3.4
'@rolldown/binding-linux-arm64-gnu': 1.3.4
'@rolldown/binding-linux-arm64-musl': 1.3.4
'@rolldown/binding-linux-ppc64-gnu': 1.3.4
'@rolldown/binding-linux-s390x-gnu': 1.3.4
'@rolldown/binding-linux-x64-gnu': 1.3.4
'@rolldown/binding-linux-x64-musl': 1.3.4
'@rolldown/binding-openharmony-arm64': 1.3.4
'@rolldown/binding-wasm32-wasi': 1.3.4
'@rolldown/binding-win32-arm64-msvc': 1.3.4
'@rolldown/binding-win32-x64-msvc': 1.3.4
[email protected]:
dependencies:
@@ -3238,7 +3233,7 @@ snapshots:
pathe: 2.0.3
picomatch: 4.0.7
[email protected]([email protected])(rolldown@1.2.18)(vite@8.3.8([email protected])([email protected])):
[email protected]([email protected])(rolldown@1.3.4)(vite@8.4.0([email protected])([email protected])):
dependencies:
'@jridgewell/remapping': 2.3.5
'@rolldown/pluginutils': 1.0.1
@@ -3246,25 +3241,26 @@ snapshots:
webpack-virtual-modules: 0.6.2
optionalDependencies:
esbuild: 0.28.2
rolldown: 1.2.18
vite: 8.3.8([email protected])([email protected])
rolldown: 1.3.4
vite: 8.4.0([email protected])([email protected])
vite@8.3.8([email protected])([email protected]):
vite@8.4.0([email protected])([email protected]):
dependencies:
lightningcss: 1.33.0
picomatch: 4.0.7
postcss: 8.5.32
rolldown: 1.2.18
postcss: 8.5.34
rolldown: 1.3.4
tinyglobby: 0.2.17
optionalDependencies:
esbuild: 0.28.2
fsevents: 2.3.3
jiti: 2.7.0
napi-windows-process-start-time: 0.1.0
[email protected].1([email protected])(vite@8.3.8([email protected])([email protected])):
[email protected].2([email protected])(vite@8.4.0([email protected])([email protected])):
dependencies:
'@types/chai': 5.2.3
'@vitest/mocker': 5.1.1(vite@8.3.8([email protected])([email protected]))
'@vitest/mocker': 5.1.2(vite@8.4.0([email protected])([email protected]))
chai: 6.3.0
es-module-lexer: 2.3.2
expect-type: 1.4.0
@@ -3275,7 +3271,7 @@ snapshots:
tinybench: 6.2.4
tinyexec: 1.3.1
tinyglobby: 0.2.17
vite: 8.3.8([email protected])([email protected])
vite: 8.4.0([email protected])([email protected])
why-is-node-running: 3.2.1
optionalDependencies:
jsdom: 31.0.1
@@ -3297,7 +3293,7 @@ snapshots:
[email protected]: {}
[email protected].1(@vue/[email protected]5)([email protected])([email protected](@vue/[email protected])([email protected])([email protected]([email protected])))(rolldown@1.2.18)(vite@8.3.8([email protected])([email protected]))([email protected]([email protected])):
[email protected].3(@vue/[email protected]6)([email protected])([email protected](@vue/[email protected])([email protected])([email protected]([email protected])))(rolldown@1.3.4)(vite@8.4.0([email protected])([email protected]))([email protected]([email protected])):
dependencies:
'@vue-macros/common': 3.1.4([email protected]([email protected]))
'@vue/devtools-api': 8.2.1
@@ -3307,19 +3303,19 @@ snapshots:
local-pkg: 2.0.0
magic-string: 1.4.5
mlly: 1.8.2
muggle-string: 0.4.1
muggle-string: 1.0.5
nostics: 1.3.0
pathe: 2.0.3
picomatch: 4.0.7
scule: 1.3.0
tinyglobby: 0.2.17
unplugin: 3.7.0([email protected])(rolldown@1.2.18)(vite@8.3.8([email protected])([email protected]))
unplugin: 3.7.0([email protected])(rolldown@1.3.4)(vite@8.4.0([email protected])([email protected]))
unplugin-utils: 0.3.2
vue: 3.5.46([email protected])
optionalDependencies:
'@vue/compiler-sfc': 3.5.45
'@vue/compiler-sfc': 3.5.46
pinia: 4.1.0(@vue/[email protected])([email protected])([email protected]([email protected]))
vite: 8.3.8([email protected])([email protected])
vite: 8.4.0([email protected])([email protected])
transitivePeerDependencies:
- '@farmfe/core'
- '@rsbuild/core'
+19 -19
View File
@@ -3,13 +3,13 @@ module github.com/lukaszraczylo/gohoarder
go 1.26.0
require (
github.com/aws/aws-sdk-go-v2 v1.48.0
github.com/aws/aws-sdk-go-v2/config v1.33.21
github.com/aws/aws-sdk-go-v2/credentials v1.21.3
github.com/aws/aws-sdk-go-v2/service/s3 v1.116.0
github.com/aws/aws-sdk-go-v2 v1.48.2
github.com/aws/aws-sdk-go-v2/config v1.33.23
github.com/aws/aws-sdk-go-v2/credentials v1.21.5
github.com/aws/aws-sdk-go-v2/service/s3 v1.116.2
github.com/cloudsoda/go-smb2 v0.0.0-20261105190815-95be04a983b8
github.com/go-gormigrate/gormigrate/v2 v2.1.7
github.com/go-sql-driver/mysql v1.10.2
github.com/go-sql-driver/mysql v1.11.0
github.com/goccy/go-json v0.12.0
github.com/gofiber/fiber/v3 v3.7.0
github.com/gorilla/websocket v1.5.3
@@ -37,20 +37,20 @@ require (
filippo.io/edwards25519 v1.2.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20261006220739-8c912ac31dd4 // indirect
github.com/Microsoft/go-winio v0.6.4 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.27 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.20.9 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.12 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.12 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.12 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.25 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.11.13 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.12 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.20.12 // indirect
github.com/aws/aws-sdk-go-v2/service/signin v1.14.0 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.39.5 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.44.5 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.53.0 // indirect
github.com/aws/smithy-go v1.28.10 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.29 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.20.11 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.14 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.14 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.14 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.27 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.11.15 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.14 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.20.14 // indirect
github.com/aws/aws-sdk-go-v2/service/signin v1.14.2 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.39.7 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.44.7 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.53.2 // indirect
github.com/aws/smithy-go v1.28.11 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
+38 -38
View File
@@ -8,42 +8,42 @@ github.com/Azure/go-ansiterm v0.0.0-20261006220739-8c912ac31dd4 h1:m2xcjRABtG288
github.com/Azure/go-ansiterm v0.0.0-20261006220739-8c912ac31dd4/go.mod h1:MTUE7ZuZO89FAtAwozGg6AWD83pcdefnEq5gF82MB8s=
github.com/Microsoft/go-winio v0.6.4 h1:kJF2pamtYCWXf0xAT8sAkwKC0pMl2HYBrRPHAqyUc+g=
github.com/Microsoft/go-winio v0.6.4/go.mod h1:1xl5JXG4ze/m74GH6Dc4Mwxfc3VL5siRVQjIAlHH07U=
github.com/aws/aws-sdk-go-v2 v1.48.0 h1:tFU7EJVm7MfyaXLsXdYTZ0Vd6vwt9OljCyqq0gqk0Mc=
github.com/aws/aws-sdk-go-v2 v1.48.0/go.mod h1:oeKU5p+TQBnpeLmU42WZLWvzv+ORLn+74n4QVLnm/Z0=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.27 h1:3dMP9eEmHVosFN1QiD24IJBKVY8m6iUfVYXqRCT118Q=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.27/go.mod h1:KH4PKcqtjy1m0656eqQV2v53xE04ddJzuNloEKqlHkI=
github.com/aws/aws-sdk-go-v2/config v1.33.21 h1:NY1d3yXmplUSYnUAue0sR88svD+SJiaI+YJGp8TxSNg=
github.com/aws/aws-sdk-go-v2/config v1.33.21/go.mod h1:pVJNXUXaCLu9a/4/liTklg9zR3yO0xm/XBEQhgg5nzc=
github.com/aws/aws-sdk-go-v2/credentials v1.21.3 h1:bh+9VoJ4eDzJVEY6jfdNTBa0Dx7tdr+lWSPNovU1vXc=
github.com/aws/aws-sdk-go-v2/credentials v1.21.3/go.mod h1:4CNs0EBvjDEpyaXSYCdNeNRhFjHFX2Y373tFUaeTYXA=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.20.9 h1:oH1E0tjN0g+ZRusbX1dsuat4FJ0z05l8hWaycSbDuNc=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.20.9/go.mod h1:3ZaQGigIoaS45x9HgnLZ4sP475Fs7QoxU3IsZX/J3h4=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.12 h1:W0yUUzKBA8SofGQ0yZafEUuZq9UxfvijRgdc6vcRQPA=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.12/go.mod h1:xwKv6vwBNdpPFOxEm/ld4IODZK2s/1ksHvdBqLfH6Gs=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.12 h1:lqSi8qvAnKC1vfosImdmOsuiJLr/jdybZX5299beB6Q=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.12/go.mod h1:rqPQE2vqkW9YHx5+Gp55sx1wsTM4xtGQLl+TKMjxxrs=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.12 h1:uvX2yaL+aMjkmnrLPPlR/zwjoKFRMoNhhJfeGjfk6qc=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.12/go.mod h1:dicT+2eNhHHqGkxHO7LoXw3QghIUGuzgdmFqaSTopgI=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.25 h1:rKwkY3Z+fvt2W0msjdNs6uNewPmXzPayQ961oyuWhes=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.25/go.mod h1:dBuAadQKd1F4Q4ZOg8gnFmuSHMRE40Pe3IfFwbtC4lE=
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.11.13 h1:U5HZ8FpTr6tyvulf1nT11Nw4KG1CAsXkuQGdUrIjZ/E=
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.11.13/go.mod h1:dUfvCU1NaE+b3vqNENDiJncUQW7Djl5pmgUlcjesVqk=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.12 h1:wzAqMZ2O4+ij9HQqIrk+P9PBGacE0wOTuWB7Mo97//I=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.12/go.mod h1:/0TfyruByHsOlphzP26xDTRe2DKD0J1I1Uyy2TyP8EI=
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.20.12 h1:H0IaQayT3TLiGIHiNnleQZTbndDlx7LGZ0NWZ5mDwjA=
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.20.12/go.mod h1:YuJJNxaOjnknLIrscBmkLhIpnmg9LzHd25sQRKUboGU=
github.com/aws/aws-sdk-go-v2/service/s3 v1.116.0 h1:0/glEMW6lLpeGOq7tDKn3314ookbLSvzRs71Oknt6gA=
github.com/aws/aws-sdk-go-v2/service/s3 v1.116.0/go.mod h1:8NhAIBVYkVHq0hIbbzujdoou0VkKwMdG+De9e5oX6qI=
github.com/aws/aws-sdk-go-v2/service/signin v1.14.0 h1:bIEk1HfTd3MGzvDa5YOQUodGr96D9+UTnmBLBB8ZJ10=
github.com/aws/aws-sdk-go-v2/service/signin v1.14.0/go.mod h1:LdwHjKqPE9VCC7sTlWcOAizZx3ZJYjmfwC/EW2tIIAE=
github.com/aws/aws-sdk-go-v2/service/sso v1.39.5 h1:ANAoa+qt3/9kXnvQVgUyxcTzhzZf4DqaBS+M2DQrELU=
github.com/aws/aws-sdk-go-v2/service/sso v1.39.5/go.mod h1:vsMi+SSR7xGQXtV430LVi49qbv/R+U+upHHSp1W/+QI=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.44.5 h1:uIOBLMhef4N16WguadoHKuBy9etdz+RKTeqzchXErAI=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.44.5/go.mod h1:NwWmkFLtsTVyXQpbzPOlYLwEoANkdCFjJRtrNcbg/vY=
github.com/aws/aws-sdk-go-v2/service/sts v1.53.0 h1:my9Y6lxcqvPV5k4OTqnxr8XbiTDDRos1leEh050Z93U=
github.com/aws/aws-sdk-go-v2/service/sts v1.53.0/go.mod h1:MG6N8U9+lY4LqchrlHPqCOSr7hyxw70XU0Et2YR3eNA=
github.com/aws/smithy-go v1.28.10 h1:SfPnj8fGCVAI/P5YC4/1JjuMsucbPp2dROnSTYNo2PE=
github.com/aws/smithy-go v1.28.10/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc=
github.com/aws/aws-sdk-go-v2 v1.48.2 h1:TDS0/5Z/UjdvmB0jg+8j6a80n5OCRyvrn3aOtZ6z0M4=
github.com/aws/aws-sdk-go-v2 v1.48.2/go.mod h1:XwfdWCjuiyYPbYF4ObLoa5I25KjV0ry6d105smVjNKY=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.29 h1:LfdRwpJ0Dfh+vpqHevmmnFnMoc3/lfB4pdHOfWpLfH4=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.29/go.mod h1:r6fijnrGRQ4OnSGyHYuFcC7G6wdwB4Ld8WhiIaGZHx0=
github.com/aws/aws-sdk-go-v2/config v1.33.23 h1:HA00lA653ZbSD7ORNyLmyWbbkcUc5j78eD0YVCe8cVM=
github.com/aws/aws-sdk-go-v2/config v1.33.23/go.mod h1:RAPX60IQ+derVWkbQ0zK0+wDZIOLeTaSmfIw1h9nITA=
github.com/aws/aws-sdk-go-v2/credentials v1.21.5 h1:Jc81YgP1HASD9WEfYcZlv4v3hBFgjsPvhEC3KFvoPPc=
github.com/aws/aws-sdk-go-v2/credentials v1.21.5/go.mod h1:pocCtlNZjN5obeULq1nBtiUwER1I/eUOCc3mOWVB4Qs=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.20.11 h1:X02TWwl2Dl5+McRWMcLCss+xu/TQW6f+nhW01zK3F+I=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.20.11/go.mod h1:RSXLfa6vJ3Ed7lRNqaB/bkO0LeyiedfSdQ/77z0j0+o=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.14 h1:0a6o5QglM7yIYPBtuU2I0cts4GmoxKq9CI4QXhoYjwU=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.5.14/go.mod h1:97hjZ6DMSiOIc1yO/nkExfwEtyS3TTTwLTc4djsPV6M=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.14 h1:JxqxML276jtkfjQxKgAeSSCH5IaK2q8SxxNBLpjdd8g=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.8.14/go.mod h1:w22QsiUhclV6A0d6unKN6TpwWFWTRBMa1Rt/B3gs7b8=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.14 h1:yp9x98m1JqB3V/pQkfa+0uzyu9CUIfqNm5IVlFqXaZE=
github.com/aws/aws-sdk-go-v2/internal/v4a v1.5.14/go.mod h1:OWqBN2lc37Pd1XDcBtl2l+vfgKrnfVM2vStOSCCI608=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.27 h1:2jIfOe8ZuoStxOkRtVU45zxgvt/qeIRChhm2USOS6g8=
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.27/go.mod h1:LpMjYa8iT3kMkAxsVCGfyXkBDOOKsziY6S2wSpEvY70=
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.11.15 h1:jRCwllodRzOfdUZnty07OPuAl/Z3VFg+G/0KnAAZgqE=
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.11.15/go.mod h1:SfcL32Le6U1WSuswx/ZdGWwYwgP8F5CSV0H9VOlnyiU=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.14 h1:+uYcwTJB+5UhLrhxkOKUpR6+ls5ckbHqHC49M7crIOg=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.14.14/go.mod h1:POa4UPRV0vUNxPl2brT7/TmPHsFZvKP86DT0eTxV9C4=
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.20.14 h1:CWUq3u37DMC2zmYrGcDB/z/jwhzM1Te/+Jcdif2ruH4=
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.20.14/go.mod h1:LVGrFyfnwjZAySQFrjb+RcFomBHFgzwR+b5FVrPpcnI=
github.com/aws/aws-sdk-go-v2/service/s3 v1.116.2 h1:ueJDp7iBzU4PPo+kRHdkgAXWQ0MNELoebDHSnPinVWg=
github.com/aws/aws-sdk-go-v2/service/s3 v1.116.2/go.mod h1:AJxrBhiUkirKaX6X4SwyQQYcYy66zrcpAKrhvevekWY=
github.com/aws/aws-sdk-go-v2/service/signin v1.14.2 h1:jY6/9VqXDU4CBpd4RkG12VvbOWKEP3jNo5wZnz1rFSE=
github.com/aws/aws-sdk-go-v2/service/signin v1.14.2/go.mod h1:InhTMDzNCNRSILLyYU2jepaIzKRK/Oj0QaKwJeCVWcA=
github.com/aws/aws-sdk-go-v2/service/sso v1.39.7 h1:M+J+44edhVK8f9Y0U9owjPOfGjBmH9lrY4xHoLbK22g=
github.com/aws/aws-sdk-go-v2/service/sso v1.39.7/go.mod h1:VBU8OTm/LoMUUV2OG02Zs6p/SAUg8jYBjsqJ0mRjg+E=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.44.7 h1:ZqLoBJ9CBOmzDCBR1SyOdzgVARtATujw2YK3Qezzzg0=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.44.7/go.mod h1:EJ4AvTQMTGCO+ThDWJ5rINFfSSXOAni8uWHDgoD7/pQ=
github.com/aws/aws-sdk-go-v2/service/sts v1.53.2 h1:nLsYkVhvseSf0aBwvXwEjoYn9vN3GWGqlJYqH1zShmA=
github.com/aws/aws-sdk-go-v2/service/sts v1.53.2/go.mod h1:7f/XsI45+GK2yL0Gg0gojsNXVlXx9+qtCSYk2HdE308=
github.com/aws/smithy-go v1.28.11 h1:2aArhkXe0dFld6IFMlaVy47SbSdU/ZGbDaE7X2DjZkI=
github.com/aws/smithy-go v1.28.11/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
@@ -97,8 +97,8 @@ github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
github.com/go-sql-driver/mysql v1.10.2 h1:5TRvGvczDohUMOCRA5aCAXgfSZOo/oNDSFD/2RrChS0=
github.com/go-sql-driver/mysql v1.10.2/go.mod h1:M+cqaI7+xxXGG9swrdeUIoPG3Y3KCkF0pZej+SK+nWk=
github.com/go-sql-driver/mysql v1.11.0 h1:0dFnuu2mR7g+8Smo/rL18y1WnTLgVrHttzSahf20Gb4=
github.com/go-sql-driver/mysql v1.11.0/go.mod h1:evJsoGjlO/9BFsnfXyjtluDYb3OSGzPNOnUaBl/2Dao=
github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro=
github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
github.com/goccy/go-json v0.12.0 h1:pD+oWouAiz4yruwXIt/iT+lOMeyhr1aTtxzaMP/RgVI=
+8 -6
View File
@@ -214,9 +214,10 @@ type ScannersConfig struct {
// TrivyConfig contains Trivy scanner configuration
type TrivyConfig struct {
CacheDB string `mapstructure:"cache_db" json:"cache_db"`
Timeout time.Duration `mapstructure:"timeout" json:"timeout"`
Enabled bool `mapstructure:"enabled" json:"enabled"`
CacheDB string `mapstructure:"cache_db" json:"cache_db"`
Timeout time.Duration `mapstructure:"timeout" json:"timeout"`
DBUpdateInterval time.Duration `mapstructure:"db_update_interval" json:"db_update_interval"` // 0 = 6h
Enabled bool `mapstructure:"enabled" json:"enabled"`
}
// OSVConfig contains OSV scanner configuration
@@ -410,9 +411,10 @@ func Default() *Config {
},
Scanners: ScannersConfig{
Trivy: TrivyConfig{
Enabled: false,
Timeout: 5 * time.Minute,
CacheDB: "/var/lib/trivy",
Enabled: false,
Timeout: 5 * time.Minute,
CacheDB: "/var/lib/trivy",
DBUpdateInterval: 6 * time.Hour,
},
OSV: OSVConfig{
Enabled: false,
+45
View File
@@ -0,0 +1,45 @@
// Package dbrefresh runs a scanner's vulnerability database update on a fixed interval.
package dbrefresh
import (
"context"
"time"
"github.com/rs/zerolog/log"
)
// DefaultInterval applies when the configured interval is 0.
const DefaultInterval = 6 * time.Hour
// Run calls update every interval until stop closes. immediate runs the first update at once;
// otherwise it waits one interval.
func Run(stop <-chan struct{}, interval time.Duration, immediate bool, scanner string, update func(context.Context) error) {
if interval <= 0 {
interval = DefaultInterval
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
go func() {
<-stop
cancel()
}()
once := func() {
if err := update(ctx); err != nil {
log.Error().Err(err).Str("scanner", scanner).Msg("Scheduled database update failed")
}
}
if immediate {
once()
}
ticker := time.NewTicker(interval)
defer ticker.Stop()
for {
select {
case <-ticker.C:
once()
case <-ctx.Done():
return
}
}
}
+8 -7
View File
@@ -22,6 +22,7 @@ import (
"github.com/lukaszraczylo/gohoarder/pkg/scanner/gomodule"
"github.com/lukaszraczylo/gohoarder/pkg/scanner/scanerr"
"github.com/lukaszraczylo/gohoarder/pkg/scanner/scanver"
"github.com/lukaszraczylo/gohoarder/pkg/scanner/workdir"
"github.com/lukaszraczylo/gohoarder/pkg/uuid"
"github.com/rs/zerolog/log"
)
@@ -79,15 +80,15 @@ func (s *Scanner) Scan(ctx context.Context, registry, packageName, version strin
fmt.Sprintf("not a module path and version: %q %q", module, version), ""), nil
}
tmpDir, err := os.MkdirTemp("", "govulncheck-*")
wd, err := workdir.New(ScannerName)
if err != nil {
return nil, err
}
defer wd.Remove()
tmpDir, err := os.MkdirTemp(wd.Path(), "govulncheck-*")
if err != nil {
return nil, fmt.Errorf("failed to create temp dir: %w", err)
}
defer func() {
if rmErr := os.RemoveAll(tmpDir); rmErr != nil {
log.Warn().Err(rmErr).Str("scanner", ScannerName).Str("dir", tmpDir).Msg("Cannot remove scan directory")
}
}()
// govulncheck never reports advisories against the main module of the tree it scans, so
// scanning the module's own source reports a vulnerable module clean. The module is
@@ -96,7 +97,7 @@ func (s *Scanner) Scan(ctx context.Context, registry, packageName, version strin
// Resolving the module reaches the module proxy.
// The dependency tree goes to a module cache inside tmpDir, so the scan keeps nothing on disk;
// -modcacherw leaves that cache writable, or RemoveAll cannot delete it.
env := append(os.Environ(), "GOFLAGS=-mod=mod -modcacherw", "GOTOOLCHAIN=local", "GOWORK=off",
env := append(wd.Env(os.Environ()), "GOFLAGS=-mod=mod -modcacherw", "GOTOOLCHAIN=local", "GOWORK=off",
"GOMODCACHE="+filepath.Join(tmpDir, "modcache"))
goMod := fmt.Sprintf("module gohoarder.audit\n\nrequire %s %s\n", module, version)
if err = os.WriteFile(filepath.Join(tmpDir, "go.mod"), []byte(goMod), 0o600); err != nil {
+2 -31
View File
@@ -1,7 +1,6 @@
package grype
import (
"context"
"errors"
"io/fs"
"os"
@@ -9,11 +8,11 @@ import (
"strings"
"time"
"github.com/lukaszraczylo/gohoarder/pkg/scanner/dbrefresh"
"github.com/rs/zerolog/log"
)
const (
defaultDBUpdateInterval = 6 * time.Hour
// grype's own limits are 30s for the update check and 5m for the download.
dbUpdateTimeout = 10 * time.Minute
// Far past dbUpdateTimeout, so only a download whose grype process died is removed.
@@ -27,35 +26,7 @@ const (
// RefreshDatabase updates the database every interval until stop closes. immediate runs
// the first update at once; otherwise it waits one interval. interval 0 means 6h.
func (s *Scanner) RefreshDatabase(stop <-chan struct{}, interval time.Duration, immediate bool) {
if interval <= 0 {
interval = defaultDBUpdateInterval
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
go func() {
<-stop
cancel()
}()
if immediate {
s.refreshOnce(ctx)
}
ticker := time.NewTicker(interval)
defer ticker.Stop()
for {
select {
case <-ticker.C:
s.refreshOnce(ctx)
case <-ctx.Done():
return
}
}
}
func (s *Scanner) refreshOnce(ctx context.Context) {
if err := s.UpdateDatabase(ctx); err != nil {
log.Error().Err(err).Str("scanner", ScannerName).Msg("Scheduled Grype database update failed")
}
dbrefresh.Run(stop, interval, immediate, ScannerName, s.UpdateDatabase)
}
// dbCacheDir mirrors grype's db.cache-dir default and its GRYPE_DB_CACHE_DIR override.
+7 -1
View File
@@ -17,6 +17,7 @@ import (
"github.com/lukaszraczylo/gohoarder/pkg/metadata"
"github.com/lukaszraczylo/gohoarder/pkg/scanner/gomodule"
"github.com/lukaszraczylo/gohoarder/pkg/scanner/scanver"
"github.com/lukaszraczylo/gohoarder/pkg/scanner/workdir"
"github.com/lukaszraczylo/gohoarder/pkg/uuid"
"github.com/rs/zerolog/log"
)
@@ -56,9 +57,14 @@ func (s *Scanner) Scan(ctx context.Context, registry, packageName, version strin
if target == "" {
target = filePath
}
wd, err := workdir.New(ScannerName)
if err != nil {
return nil, err
}
defer wd.Remove()
cmd := exec.CommandContext(ctx, "grype", target, "-o", "json", "-q") // #nosec G204 -- target is a purl or the stored artifact path
// Concurrent scans each downloading the database filled the disk; RefreshDatabase owns updates.
cmd.Env = append(os.Environ(), "GRYPE_DB_AUTO_UPDATE=false")
cmd.Env = append(wd.Env(os.Environ()), "GRYPE_DB_AUTO_UPDATE=false")
var stderr bytes.Buffer
cmd.Stderr = &stderr
output, err := cmd.Output()
+72
View File
@@ -0,0 +1,72 @@
package scanner_test
import (
"context"
"os"
"path/filepath"
"testing"
"time"
"github.com/lukaszraczylo/gohoarder/pkg/config"
"github.com/lukaszraczylo/gohoarder/pkg/metadata"
"github.com/lukaszraczylo/gohoarder/pkg/scanner/govulncheck"
"github.com/lukaszraczylo/gohoarder/pkg/scanner/grype"
"github.com/lukaszraczylo/gohoarder/pkg/scanner/npmaudit"
"github.com/lukaszraczylo/gohoarder/pkg/scanner/pipaudit"
"github.com/lukaszraczylo/gohoarder/pkg/scanner/scannertest"
"github.com/lukaszraczylo/gohoarder/pkg/scanner/trivy"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// trivyCache returns a trivy cache dir that already holds a database.
func trivyCache(t *testing.T) string {
t.Helper()
dir := t.TempDir()
require.NoError(t, os.MkdirAll(filepath.Join(dir, "db"), 0o750))
require.NoError(t, os.WriteFile(filepath.Join(dir, "db", "trivy.db"), nil, 0o600))
return dir
}
type scanFunc func(ctx context.Context, registry, packageName, version, filePath string) (*metadata.ScanResult, error)
// A scanner binary killed by its timeout never removes its own temp files: a killed trivy
// leaves its database download (trivy-<n>, getter<n>, up to 279 MB) in TMPDIR.
func TestScanLeavesNothingInTheTempDir(t *testing.T) {
const leave = `mkdir -p "$TMPDIR/trivy-1/db" "$TMPDIR/getter1" && echo x > "$TMPDIR/trivy-1/db/trivy.db"`
cases := []struct {
scan scanFunc
name, bin, body string
registry, pkg, ver string
}{
{name: "trivy timeout", bin: "trivy", body: leave + "\nexec sleep 5", registry: "pypi", pkg: "p", ver: "1",
scan: trivy.New(config.TrivyConfig{Timeout: time.Second, CacheDB: trivyCache(t)}).Scan},
{name: "grype failure", bin: "grype", body: leave + "\nexit 1", registry: "npm", pkg: "p", ver: "1.0.0",
scan: grype.New(config.GrypeConfig{}).Scan},
{name: "npm audit failure", bin: "npm", body: leave + "\nexit 1", registry: "npm", pkg: "p", ver: "1.0.0",
scan: npmaudit.New(config.NpmAuditConfig{}).Scan},
{name: "pip-audit failure", bin: "pip-audit", body: leave + "\nexit 1", registry: "pypi", pkg: "requests", ver: "2.0.0",
scan: pipaudit.New(config.PipAuditConfig{}).Scan},
{name: "govulncheck go list failure", bin: "go", body: leave + "\nexit 1", registry: "go", pkg: "golang.org/x/text", ver: "v0.3.5",
scan: govulncheck.New(config.GovulncheckConfig{}).Scan},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
scannertest.Script(t, tc.bin, tc.body)
archive := filepath.Join(t.TempDir(), "p.tgz")
require.NoError(t, os.WriteFile(archive, []byte("x"), 0o600))
tmp := t.TempDir()
t.Setenv("TMPDIR", tmp)
_, _ = tc.scan(context.Background(), tc.registry, tc.pkg, tc.ver, archive)
left, err := os.ReadDir(tmp)
require.NoError(t, err)
names := make([]string, 0, len(left))
for _, e := range left {
names = append(names, e.Name())
}
assert.Empty(t, names)
})
}
}
+9 -2
View File
@@ -18,6 +18,7 @@ import (
"github.com/lukaszraczylo/gohoarder/pkg/metadata"
"github.com/lukaszraczylo/gohoarder/pkg/scanner/scanerr"
"github.com/lukaszraczylo/gohoarder/pkg/scanner/scanver"
"github.com/lukaszraczylo/gohoarder/pkg/scanner/workdir"
"github.com/lukaszraczylo/gohoarder/pkg/uuid"
"github.com/rs/zerolog/log"
)
@@ -69,11 +70,15 @@ func (s *Scanner) Scan(ctx context.Context, registry, packageName, version strin
Str("version", version).
Msg("Starting npm audit scan")
tmpDir, err := os.MkdirTemp("", "npm-audit-*")
wd, err := workdir.New(ScannerName)
if err != nil {
return nil, err
}
defer wd.Remove()
tmpDir, err := os.MkdirTemp(wd.Path(), "npm-audit-*")
if err != nil {
return nil, fmt.Errorf("failed to create temp dir: %w", err)
}
defer func() { _ = os.RemoveAll(tmpDir) }()
if err = writeWrapper(tmpDir, packageName, filePath); err != nil {
return s.scanErrorResult(ctx, registry, packageName, version, fmt.Sprintf("prepare audit project: %v", err), ""), nil
@@ -95,6 +100,7 @@ func (s *Scanner) Scan(ctx context.Context, registry, packageName, version strin
"--no-fund",
)
installCmd.Dir = tmpDir
installCmd.Env = wd.Env(os.Environ())
if installOut, installErr := installCmd.CombinedOutput(); installErr != nil {
log.Warn().
Err(installErr).
@@ -107,6 +113,7 @@ func (s *Scanner) Scan(ctx context.Context, registry, packageName, version strin
cmd := exec.CommandContext(ctx, "npm", "audit", "--omit=dev", "--json") // #nosec G204 -- fixed args
cmd.Dir = tmpDir
cmd.Env = installCmd.Env
var stderr bytes.Buffer
cmd.Stderr = &stderr
output, _ := cmd.Output() // npm audit exits non-zero when it finds vulnerabilities
+8 -2
View File
@@ -18,6 +18,7 @@ import (
"github.com/lukaszraczylo/gohoarder/pkg/metadata"
"github.com/lukaszraczylo/gohoarder/pkg/scanner/scanerr"
"github.com/lukaszraczylo/gohoarder/pkg/scanner/scanver"
"github.com/lukaszraczylo/gohoarder/pkg/scanner/workdir"
"github.com/lukaszraczylo/gohoarder/pkg/uuid"
"github.com/rs/zerolog/log"
)
@@ -74,11 +75,15 @@ func (s *Scanner) Scan(ctx context.Context, registry, packageName, version strin
fmt.Sprintf("not a project name and version: %q %q", packageName, version), ""), nil
}
tmpDir, err := os.MkdirTemp("", "pip-audit-*")
wd, err := workdir.New(ScannerName)
if err != nil {
return nil, err
}
defer wd.Remove()
tmpDir, err := os.MkdirTemp(wd.Path(), "pip-audit-*")
if err != nil {
return nil, fmt.Errorf("failed to create temp dir: %w", err)
}
defer func() { _ = os.RemoveAll(tmpDir) }()
// pip-audit has no wheel or sdist input: its positional argument is a project directory. The
// release is audited by its pinned name and version. --no-deps and --disable-pip keep it to
@@ -89,6 +94,7 @@ func (s *Scanner) Scan(ctx context.Context, registry, packageName, version strin
}
cmd := exec.CommandContext(ctx, "pip-audit", "-r", reqFile, "--no-deps", "--disable-pip", "-f", "json") // #nosec G204 -- name and version are validated, file is in a controlled temp dir
cmd.Env = wd.Env(os.Environ())
var stderr bytes.Buffer
cmd.Stderr = &stderr
output, _ := cmd.Output() // pip-audit exits non-zero when it finds vulnerabilities
+2
View File
@@ -238,6 +238,8 @@ func New(cfg config.SecurityConfig, metadataStore metadata.MetadataStore) (*Mana
log.Warn().Err(err).Msg("Failed to update Trivy database on startup")
}
}
// Scans never update the database, so without this loop it ages past its NextUpdate.
go trivyScanner.RefreshDatabase(manager.stopCh, cfg.Scanners.Trivy.DBUpdateInterval, !cfg.UpdateDBOnStartup)
}
// Initialize OSV scanner
+115
View File
@@ -0,0 +1,115 @@
package trivy
import (
"context"
"os"
"path/filepath"
"strings"
"sync"
"testing"
"time"
"github.com/lukaszraczylo/gohoarder/pkg/config"
"github.com/lukaszraczylo/gohoarder/pkg/metadata"
"github.com/lukaszraczylo/gohoarder/pkg/scanner/scannertest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// withDB returns cfg with a cache dir that already holds a database.
func withDB(t *testing.T, cfg config.TrivyConfig) config.TrivyConfig {
t.Helper()
cfg.CacheDB = t.TempDir()
require.NoError(t, os.MkdirAll(filepath.Join(cfg.CacheDB, "db"), 0o750))
require.NoError(t, os.WriteFile(filepath.Join(cfg.CacheDB, "db", "trivy.db"), nil, 0o600))
return cfg
}
// fakeTrivy downloads a database on `trivy image` and scans clean otherwise, logging each step.
func fakeTrivy(t *testing.T, scanSleep string) (logFile string) {
t.Helper()
logFile = filepath.Join(t.TempDir(), "log")
scannertest.Script(t, "trivy", `
if [ "$1" = image ]; then
echo update >> '`+logFile+`'
mkdir -p "$TRIVY_CACHE_DIR/db" && : > "$TRIVY_CACHE_DIR/db/trivy.db"
exit 0
fi
echo scan-start >> '`+logFile+`'
sleep `+scanSleep+`
echo scan-end >> '`+logFile+`'
echo '{"Results":[]}'`)
return logFile
}
func readLog(t *testing.T, logFile string) []string {
t.Helper()
data, err := os.ReadFile(logFile) // #nosec G304 -- test temp file
require.NoError(t, err)
return strings.Fields(string(data))
}
func TestScansDownloadAMissingDatabaseOnce(t *testing.T) {
logFile := fakeTrivy(t, "0")
s := New(config.TrivyConfig{CacheDB: t.TempDir()})
var wg sync.WaitGroup
for range 4 {
wg.Add(1)
go func() {
defer wg.Done()
res, err := s.Scan(context.Background(), "pypi", "p", "1", "/x/p.whl")
if assert.NoError(t, err) {
assert.Equal(t, metadata.ScanStatusClean, res.Status)
}
}()
}
wg.Wait()
lines := readLog(t, logFile)
assert.Equal(t, "update", lines[0])
assert.Equal(t, 1, strings.Count(strings.Join(lines, " "), "update"))
}
// Concurrent trivy processes replacing the database under running scans crashed them with SIGBUS.
func TestUpdateWaitsForRunningScans(t *testing.T) {
logFile := fakeTrivy(t, "0.3")
s := New(withDB(t, config.TrivyConfig{}))
done := make(chan struct{})
go func() {
defer close(done)
_, err := s.Scan(context.Background(), "pypi", "p", "1", "/x/p.whl")
assert.NoError(t, err)
}()
require.Eventually(t, func() bool {
data, _ := os.ReadFile(logFile) // #nosec G304 -- test temp file
return strings.Contains(string(data), "scan-start")
}, 5*time.Second, 5*time.Millisecond)
require.NoError(t, s.UpdateDatabase(context.Background()))
<-done
assert.Equal(t, []string{"scan-start", "scan-end", "update"}, readLog(t, logFile))
}
func TestRefreshDatabaseRunsOnInterval(t *testing.T) {
logFile := fakeTrivy(t, "0")
stop := make(chan struct{})
exited := make(chan struct{})
go func() {
New(config.TrivyConfig{CacheDB: t.TempDir()}).RefreshDatabase(stop, 20*time.Millisecond, true)
close(exited)
}()
require.Eventually(t, func() bool {
data, _ := os.ReadFile(logFile) // #nosec G304 -- test temp file
return strings.Count(string(data), "update\n") >= 3
}, 5*time.Second, 10*time.Millisecond)
close(stop)
select {
case <-exited:
case <-time.After(2 * time.Second):
t.Fatal("refresh loop did not stop")
}
}
+3 -3
View File
@@ -18,12 +18,12 @@ const maxExtractBytes int64 = 512 << 20
var errTooLarge = errors.New("archive exceeds the extraction size limit")
// unpackNPM extracts an npm tarball into root/node_modules/<name>, the layout trivy's node-pkg
// analyzer reads. It returns root, which the caller must remove.
func unpackNPM(archive, name string) (root string, err error) {
// analyzer reads. root is a new dir in parent.
func unpackNPM(parent, archive, name string) (root string, err error) {
if !validPackageName(name) {
return "", fmt.Errorf("unsafe package name %q", name)
}
root, err = os.MkdirTemp("", "trivy-npm-*")
root, err = os.MkdirTemp(parent, "trivy-npm-*")
if err != nil {
return "", err
}
+87 -13
View File
@@ -8,13 +8,17 @@ import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
"sync"
"time"
"github.com/lukaszraczylo/gohoarder/pkg/config"
"github.com/lukaszraczylo/gohoarder/pkg/metadata"
"github.com/lukaszraczylo/gohoarder/pkg/scanner/dbrefresh"
"github.com/lukaszraczylo/gohoarder/pkg/scanner/scanerr"
"github.com/lukaszraczylo/gohoarder/pkg/scanner/scanver"
"github.com/lukaszraczylo/gohoarder/pkg/scanner/workdir"
"github.com/lukaszraczylo/gohoarder/pkg/uuid"
"github.com/rs/zerolog/log"
)
@@ -22,10 +26,16 @@ import (
// ScannerName is the name of this scanner
const ScannerName = "trivy"
// A full download takes about 11s; this bounds a hung one, during which scans wait.
const dbUpdateTimeout = 10 * time.Minute
// Scanner implements the Scanner interface using Trivy
type Scanner struct {
version scanver.Cache
config config.TrivyConfig
// Scans hold the read lock, updates the write lock: trivy processes that read the database
// while another replaced it crashed with SIGBUS.
dbMu sync.RWMutex
}
// TrivyResult represents Trivy JSON output structure
@@ -85,14 +95,63 @@ func (s *Scanner) Name() string {
return ScannerName
}
// UpdateDatabase updates Trivy's vulnerability database
// UpdateDatabase updates Trivy's vulnerability database. It waits for running scans, and
// scans wait for it.
func (s *Scanner) UpdateDatabase(ctx context.Context) error {
s.dbMu.Lock()
defer s.dbMu.Unlock()
return s.download(ctx)
}
// RefreshDatabase updates the database every interval until stop closes. immediate runs
// the first update at once; otherwise it waits one interval. interval 0 means 6h.
func (s *Scanner) RefreshDatabase(stop <-chan struct{}, interval time.Duration, immediate bool) {
dbrefresh.Run(stop, interval, immediate, ScannerName, s.UpdateDatabase)
}
// ensureDatabase downloads the database when the cache has none: a scan never updates it.
func (s *Scanner) ensureDatabase(ctx context.Context) error {
if s.hasDatabase() {
return nil
}
s.dbMu.Lock()
defer s.dbMu.Unlock()
if s.hasDatabase() {
return nil
}
return s.download(ctx)
}
// hasDatabase reports whether trivy's cache dir holds a vulnerability database.
func (s *Scanner) hasDatabase() bool {
dir := s.config.CacheDB
if dir == "" {
dir = os.Getenv("TRIVY_CACHE_DIR")
}
if dir == "" {
cache, err := os.UserCacheDir()
if err != nil {
return false
}
dir = filepath.Join(cache, "trivy")
}
_, err := os.Stat(filepath.Join(dir, "db", "trivy.db")) // #nosec G703 -- cache dir from config or env
return err == nil
}
// download runs the database update. The caller holds the write lock.
func (s *Scanner) download(ctx context.Context) error {
log.Info().Msg("Updating Trivy vulnerability database")
cmd := exec.CommandContext(ctx, "trivy", "image", "--download-db-only")
if s.config.CacheDB != "" {
cmd.Env = append(os.Environ(), fmt.Sprintf("TRIVY_CACHE_DIR=%s", s.config.CacheDB))
wd, err := workdir.New(ScannerName)
if err != nil {
return err
}
defer wd.Remove()
ctx, cancel := context.WithTimeout(ctx, dbUpdateTimeout)
defer cancel()
cmd := exec.CommandContext(ctx, "trivy", "image", "--download-db-only")
cmd.Env = s.env(wd)
output, err := cmd.CombinedOutput()
if err != nil {
@@ -105,6 +164,12 @@ func (s *Scanner) UpdateDatabase(ctx context.Context) error {
// Scan scans a package for vulnerabilities using Trivy
func (s *Scanner) Scan(ctx context.Context, registry, packageName, version string, filePath string) (*metadata.ScanResult, error) {
if err := s.ensureDatabase(ctx); err != nil {
return nil, fmt.Errorf("%w: %w", scanerr.ErrInfrastructure, err)
}
s.dbMu.RLock()
defer s.dbMu.RUnlock()
// Set timeout
if s.config.Timeout > 0 {
var cancel context.CancelFunc
@@ -112,31 +177,31 @@ func (s *Scanner) Scan(ctx context.Context, registry, packageName, version strin
defer cancel()
}
wd, err := workdir.New(ScannerName)
if err != nil {
return nil, err
}
defer wd.Remove()
scanType := s.determineScanType(registry, filePath)
target := filePath
if registry == "npm" {
// trivy does not unpack archives; the node-pkg analyzer needs an installed tree.
root, err := unpackNPM(filePath, packageName)
if err != nil {
if target, err = unpackNPM(wd.Path(), filePath, packageName); err != nil {
return nil, fmt.Errorf("prepare npm package for trivy: %w", err)
}
defer func() { _ = os.RemoveAll(root) }()
target = root
}
args := []string{
scanType,
"--format", "json",
"--quiet",
"--skip-db-update", // RefreshDatabase owns updates
target,
}
cmd := exec.CommandContext(ctx, "trivy", args...) // #nosec G204 -- trivy command with controlled arguments
// Set cache directory if configured
if s.config.CacheDB != "" {
cmd.Env = append(os.Environ(), fmt.Sprintf("TRIVY_CACHE_DIR=%s", s.config.CacheDB))
}
cmd.Env = s.env(wd)
// Execute scan
output, err := cmd.Output()
@@ -168,6 +233,15 @@ func (s *Scanner) Scan(ctx context.Context, registry, packageName, version strin
return s.convertTrivyResult(&trivyResult, registry, packageName, version), nil
}
// env runs trivy in wd, with the configured cache dir.
func (s *Scanner) env(wd *workdir.Dir) []string {
env := wd.Env(os.Environ())
if s.config.CacheDB != "" {
env = append(env, "TRIVY_CACHE_DIR="+s.config.CacheDB)
}
return env
}
// determineScanType determines the appropriate Trivy scan type
func (s *Scanner) determineScanType(registry, filePath string) string {
// For now, use filesystem scan for packages
+8 -9
View File
@@ -23,7 +23,7 @@ import (
func TestScanTimeoutIsAnInfrastructureErrorResult(t *testing.T) {
scannertest.Script(t, "trivy", "exec sleep 5")
res, err := New(config.TrivyConfig{Timeout: 100 * time.Millisecond}).Scan(context.Background(), "pypi", "p", "1", "/x")
res, err := New(withDB(t, config.TrivyConfig{Timeout: 100 * time.Millisecond})).Scan(context.Background(), "pypi", "p", "1", "/x")
require.NoError(t, err)
assert.Equal(t, metadata.ScanStatusError, res.Status)
@@ -76,7 +76,7 @@ echo '{"Results":[]}'`, rec))
entry{name: "package/lib/index.js", body: "x"},
)
res, err := New(config.TrivyConfig{}).Scan(context.Background(), "npm", "@scope/pkg", "1.0.0", archive)
res, err := New(withDB(t, config.TrivyConfig{})).Scan(context.Background(), "npm", "@scope/pkg", "1.0.0", archive)
require.NoError(t, err)
assert.Equal(t, metadata.ScanStatusClean, res.Status)
@@ -85,7 +85,7 @@ echo '{"Results":[]}'`, rec))
root, err := os.ReadFile(filepath.Join(rec, "root")) // #nosec G304 -- test temp dir
require.NoError(t, err)
lines := strings.Split(strings.TrimSpace(string(args)), "\n")
assert.Equal(t, []string{"rootfs", "--format", "json", "--quiet", strings.TrimSpace(string(root))}, lines)
assert.Equal(t, []string{"rootfs", "--format", "json", "--quiet", "--skip-db-update", strings.TrimSpace(string(root))}, lines)
pkg, err := os.ReadFile(filepath.Join(rec, "package.json")) // #nosec G304 -- test temp dir
require.NoError(t, err)
assert.JSONEq(t, `{"name":"@scope/pkg"}`, string(pkg))
@@ -95,9 +95,9 @@ echo '{"Results":[]}'`, rec))
func TestNonNPMScansTheFileWithFS(t *testing.T) {
argsFile := scannertest.Fake(t, "trivy", "", "", 0)
_, err := New(config.TrivyConfig{}).Scan(context.Background(), "pypi", "p", "1", "/x/p.whl")
_, err := New(withDB(t, config.TrivyConfig{})).Scan(context.Background(), "pypi", "p", "1", "/x/p.whl")
require.Error(t, err) // empty output is not JSON
assert.Equal(t, []string{"fs", "--format", "json", "--quiet", "/x/p.whl"}, scannertest.Args(t, argsFile))
assert.Equal(t, []string{"fs", "--format", "json", "--quiet", "--skip-db-update", "/x/p.whl"}, scannertest.Args(t, argsFile))
}
func TestExtractRejectsUnsafeArchives(t *testing.T) {
@@ -114,7 +114,7 @@ func TestExtractRejectsUnsafeArchives(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
root, err := unpackNPM(tgz(t, tt.entries...), "pkg")
root, err := unpackNPM(t.TempDir(), tgz(t, tt.entries...), "pkg")
require.Error(t, err)
assert.Empty(t, root)
})
@@ -122,12 +122,11 @@ func TestExtractRejectsUnsafeArchives(t *testing.T) {
}
func TestExtractSkipsInTreeLinksWithoutCreatingThem(t *testing.T) {
root, err := unpackNPM(tgz(t,
root, err := unpackNPM(t.TempDir(), tgz(t,
entry{name: "package/real.js", body: "x"},
entry{name: "package/l", typeflag: tar.TypeSymlink, link: "real.js"},
), "pkg")
require.NoError(t, err)
defer func() { _ = os.RemoveAll(root) }()
_, err = os.Lstat(filepath.Join(root, "node_modules", "pkg", "l"))
assert.True(t, os.IsNotExist(err))
assert.FileExists(t, filepath.Join(root, "node_modules", "pkg", "real.js"))
@@ -136,7 +135,7 @@ func TestExtractSkipsInTreeLinksWithoutCreatingThem(t *testing.T) {
func TestUnpackRejectsUnsafePackageNames(t *testing.T) {
archive := tgz(t, entry{name: "package/package.json", body: "{}"})
for _, name := range []string{"", "..", "../x", "/abs", "a/../../b", `a\b`} {
_, err := unpackNPM(archive, name)
_, err := unpackNPM(t.TempDir(), archive, name)
assert.Error(t, err, name)
}
}
+106
View File
@@ -0,0 +1,106 @@
// Package workdir gives each scanner run a private temp dir. The scanner binary gets it as
// TMPDIR, so the files it stages there, such as the database download of a trivy killed by
// its timeout, are removed with the dir.
package workdir
import (
"errors"
"fmt"
"io/fs"
"os"
"path/filepath"
"strings"
"sync"
"time"
"github.com/rs/zerolog/log"
)
const (
prefix = "gohoarder-scan-"
// Far past every scanner timeout, so a sweep never takes the dir of a scan still running elsewhere.
abandonedAfter = time.Hour
)
var (
liveMu sync.Mutex
live = map[string]struct{}{}
// One sweep at a time; concurrent scans skip it instead of queueing.
sweeping sync.Mutex
)
// Dir is the temp dir of one scanner run.
type Dir struct {
path string
}
// New sweeps abandoned work dirs, then creates one for scanner.
func New(scanner string) (*Dir, error) {
sweep(time.Now().Add(-abandonedAfter))
path, err := os.MkdirTemp("", prefix+scanner+"-*")
if err != nil {
return nil, fmt.Errorf("create scan work dir: %w", err)
}
liveMu.Lock()
live[path] = struct{}{}
liveMu.Unlock()
return &Dir{path: path}, nil
}
// Path returns the work dir.
func (d *Dir) Path() string { return d.path }
// Env returns env with TMPDIR set to the work dir; exec uses the last value of a duplicate key.
func (d *Dir) Env(env []string) []string {
return append(env, "TMPDIR="+d.path)
}
// Remove deletes the work dir and everything in it. A dir it cannot delete is left to a later sweep.
func (d *Dir) Remove() {
err := os.RemoveAll(d.path)
liveMu.Lock()
delete(live, d.path)
liveMu.Unlock()
if err != nil {
log.Warn().Err(err).Str("path", d.path).Msg("Cannot remove scan work dir")
}
}
// sweep removes work dirs last modified before cutoff that no scan in this process uses: those of
// a process killed mid-scan, and those Remove could not delete.
func sweep(cutoff time.Time) {
if !sweeping.TryLock() {
return
}
defer sweeping.Unlock()
dir := os.TempDir()
entries, err := os.ReadDir(dir)
if err != nil {
if !errors.Is(err, fs.ErrNotExist) {
log.Warn().Err(err).Str("dir", dir).Msg("Cannot list dir for abandoned scan work dirs")
}
return
}
for _, e := range entries {
if !e.IsDir() || !strings.HasPrefix(e.Name(), prefix) {
continue
}
path := filepath.Join(dir, e.Name())
liveMu.Lock()
_, inUse := live[path]
liveMu.Unlock()
if inUse {
continue
}
info, err := e.Info()
if err != nil || !info.ModTime().Before(cutoff) {
continue
}
if err := os.RemoveAll(path); err != nil {
log.Warn().Err(err).Str("path", path).Msg("Cannot remove abandoned scan work dir")
continue
}
log.Info().Str("path", path).Msg("Removed abandoned scan work dir")
}
}
+100
View File
@@ -0,0 +1,100 @@
package workdir
import (
"os"
"path/filepath"
"sync"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func entries(t *testing.T, dir string) []string {
t.Helper()
list, err := os.ReadDir(dir)
require.NoError(t, err)
names := make([]string, 0, len(list))
for _, e := range list {
names = append(names, e.Name())
}
return names
}
func TestRemoveDeletesWhatTheScannerLeft(t *testing.T) {
tmp := t.TempDir()
t.Setenv("TMPDIR", tmp)
wd, err := New("trivy")
require.NoError(t, err)
assert.Equal(t, tmp, filepath.Dir(wd.Path()))
assert.Equal(t, "TMPDIR="+wd.Path(), wd.Env([]string{"TMPDIR=/tmp"})[1])
require.NoError(t, os.MkdirAll(filepath.Join(wd.Path(), "trivy-1", "db"), 0o700))
require.NoError(t, os.WriteFile(filepath.Join(wd.Path(), "trivy-1", "db", "trivy.db"), []byte("x"), 0o600))
wd.Remove()
assert.Empty(t, entries(t, tmp))
}
func TestSweepRemovesOnlyAbandonedDirs(t *testing.T) {
tmp := t.TempDir()
t.Setenv("TMPDIR", tmp)
old := time.Now().Add(-2 * abandonedAfter)
mk := func(name string, mtime time.Time) {
path := filepath.Join(tmp, name)
require.NoError(t, os.MkdirAll(filepath.Join(path, "x"), 0o700))
require.NoError(t, os.Chtimes(path, mtime, mtime))
}
mk(prefix+"trivy-1", old)
mk(prefix+"npm-audit-2", time.Now())
mk("trivy-3", old)
live, err := New("grype")
require.NoError(t, err)
require.NoError(t, os.Chtimes(live.Path(), old, old))
sweep(time.Now().Add(-abandonedAfter))
assert.ElementsMatch(t, []string{prefix + "npm-audit-2", "trivy-3", filepath.Base(live.Path())}, entries(t, tmp))
live.Remove()
}
func TestSweepRetriesADirWhoseRemoveFailed(t *testing.T) {
tmp := t.TempDir()
t.Setenv("TMPDIR", tmp)
wd, err := New("trivy")
require.NoError(t, err)
locked := filepath.Join(wd.Path(), "locked")
require.NoError(t, os.MkdirAll(filepath.Join(locked, "f"), 0o700))
require.NoError(t, os.Chmod(locked, 0o500)) // #nosec G302 -- read-only on purpose
t.Cleanup(func() { _ = os.Chmod(locked, 0o700) }) // #nosec G302 -- test dir
wd.Remove()
require.NoError(t, os.Chmod(locked, 0o700)) // #nosec G302 -- test dir
old := time.Now().Add(-2 * abandonedAfter)
require.NoError(t, os.Chtimes(wd.Path(), old, old))
sweep(time.Now().Add(-abandonedAfter))
assert.Empty(t, entries(t, tmp))
}
func TestConcurrentScansLeaveNothing(t *testing.T) {
tmp := t.TempDir()
t.Setenv("TMPDIR", tmp)
var wg sync.WaitGroup
for range 16 {
wg.Add(1)
go func() {
defer wg.Done()
wd, err := New("npm-audit")
if !assert.NoError(t, err) {
return
}
assert.NoError(t, os.WriteFile(filepath.Join(wd.Path(), "f"), []byte("x"), 0o600))
wd.Remove()
}()
}
wg.Wait()
assert.Empty(t, entries(t, tmp))
}