w98.tmpl 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Gitleaks Security Findings Report</title>
  7. <style>
  8. :root {
  9. --primary-color: #000080;
  10. --primary-color-rgb: 0, 0, 128;
  11. --primary-dark: #000066;
  12. --primary-light: #0000aa;
  13. --secondary-color: #c0c0c0;
  14. --surface-color: #c0c0c0;
  15. --border-color: #808080;
  16. --text-color: #000000;
  17. --text-light: #404040;
  18. --text-inverse: #ffffff;
  19. --error-color: #ff0000;
  20. --warning-color: #ffaa00;
  21. --success-color: #008000;
  22. --highlight-color: rgba(0, 0, 128, 0.2);
  23. --highlight-secret: rgba(255, 0, 0, 0.2);
  24. --shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
  25. --radius: 0;
  26. --font-mono: 'Courier New', monospace;
  27. --font-main: 'MS Sans Serif', 'Tahoma', sans-serif;
  28. }
  29. * {
  30. margin: 0;
  31. padding: 0;
  32. box-sizing: border-box;
  33. }
  34. html, body {
  35. height: 100%;
  36. font-family: var(--font-main);
  37. font-size: 16px;
  38. line-height: 1.5;
  39. color: var(--text-color);
  40. background-color: #008080;
  41. background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h40v40H0V0zm20 10a10 10 0 1 1 0 20 10 10 0 0 1 0-20z' fill='%23009090' fill-opacity='0.2' fill-rule='evenodd'/%3E%3C/svg%3E");
  42. }
  43. .app-container {
  44. display: flex;
  45. flex-direction: column;
  46. height: 100%;
  47. max-width: 100%;
  48. overflow: hidden;
  49. border: 2px outset #d4d0c8;
  50. box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3);
  51. }
  52. .app-header {
  53. height: 28px;
  54. background: linear-gradient(to right, #000080, #1084d0);
  55. color: var(--text-inverse);
  56. display: flex;
  57. align-items: center;
  58. justify-content: space-between;
  59. padding: 1px 2px;
  60. flex-shrink: 0;
  61. box-shadow: var(--shadow);
  62. z-index: 10;
  63. border-bottom: 2px outset #ffffff;
  64. }
  65. .logo h1 {
  66. font-size: 14px;
  67. font-weight: bold;
  68. margin: 0;
  69. padding: 4px 2px;
  70. text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
  71. }
  72. .btn {
  73. display: inline-flex;
  74. align-items: center;
  75. justify-content: center;
  76. background-color: #c0c0c0;
  77. color: #000000;
  78. border: 2px outset #d4d0c8;
  79. border-radius: 0;
  80. font-size: 12px;
  81. padding: 3px 6px;
  82. box-shadow: 1px 1px 0 #ffffff inset, -1px -1px 0 #808080 inset;
  83. cursor: pointer;
  84. transition: background-color 0.2s, color 0.2s;
  85. font-family: var(--font-main);
  86. }
  87. .btn:active {
  88. border: 2px inset #d4d0c8;
  89. box-shadow: 1px 1px 0 #808080 inset, -1px -1px 0 #ffffff inset;
  90. padding: 4px 5px 2px 7px;
  91. }
  92. .btn-primary {
  93. background-color: var(--primary-color);
  94. color: var(--text-inverse);
  95. }
  96. .btn-primary:hover {
  97. background-color: var(--primary-dark);
  98. }
  99. .btn-sm {
  100. padding: 1px 3px;
  101. font-size: 0.75rem;
  102. }
  103. .app-main {
  104. flex: 1;
  105. overflow: auto;
  106. padding: 1.5rem;
  107. }
  108. .report-info {
  109. margin-bottom: 1.5rem;
  110. padding: 8px;
  111. background-color: #c0c0c0;
  112. border: 2px inset #d4d0c8;
  113. }
  114. .report-date {
  115. font-size: 0.875rem;
  116. color: var(--text-light);
  117. }
  118. .report-stats {
  119. display: flex;
  120. gap: 1.5rem;
  121. margin-top: 1rem;
  122. flex-wrap: wrap;
  123. }
  124. .stat-item {
  125. display: flex;
  126. flex-direction: column;
  127. gap: 0.25rem;
  128. }
  129. .stat-value {
  130. font-size: 1.25rem;
  131. font-weight: 600;
  132. }
  133. .stat-label {
  134. font-size: 0.875rem;
  135. color: var(--text-light);
  136. }
  137. .table-wrapper {
  138. overflow-x: auto;
  139. border: 2px inset #d4d0c8;
  140. }
  141. .findings-table {
  142. width: 100%;
  143. border-collapse: collapse;
  144. font-size: 0.875rem;
  145. }
  146. .findings-table th {
  147. background-color: #000080;
  148. color: white;
  149. font-weight: bold;
  150. font-size: 12px;
  151. padding: 4px 6px;
  152. border: 1px solid #808080;
  153. position: sticky;
  154. top: 0;
  155. z-index: 1;
  156. }
  157. /* Ensure table cells don't expand too much */
  158. .findings-table td {
  159. background-color: #ffffff;
  160. border: 1px solid #d4d0c8;
  161. font-size: 12px;
  162. padding: 4px 6px;
  163. vertical-align: top;
  164. max-width: 300px; /* Limit width of all cells */
  165. overflow-wrap: break-word;
  166. }
  167. .findings-table tr:hover td {
  168. background-color: #e6e6e6;
  169. }
  170. .findings-table th:nth-child(1) { width: 12%; } /* Rule */
  171. .findings-table th:nth-child(2) { width: 20%; } /* File */
  172. .findings-table th:nth-child(3) { width: 25%; } /* Description */
  173. .findings-table th:nth-child(4) { width: 20%; } /* Secret */
  174. .findings-table th:nth-child(5) { width: 23%; } /* Metadata */
  175. .secret-container {
  176. position: relative;
  177. }
  178. .match-toggle {
  179. display: inline-block;
  180. margin-top: 0.5rem;
  181. background-color: #c0c0c0;
  182. border: 2px outset #d4d0c8;
  183. color: #000000;
  184. font-size: 10px;
  185. padding: 1px 3px;
  186. cursor: pointer;
  187. }
  188. .match-toggle:active {
  189. border: 2px inset #d4d0c8;
  190. }
  191. .hidden {
  192. display: none !important;
  193. }
  194. .secret-match {
  195. font-family: var(--font-mono);
  196. font-size: 0.875rem;
  197. word-break: break-all;
  198. white-space: pre-wrap;
  199. display: block;
  200. background-color: #ffffff;
  201. border: 1px solid #808080;
  202. padding: 0.5rem;
  203. overflow-x: auto;
  204. }
  205. .tag-list {
  206. display: flex;
  207. gap: 0.25rem;
  208. flex-wrap: wrap;
  209. }
  210. .tag {
  211. display: inline-block;
  212. background-color: #000080;
  213. border-radius: 0;
  214. padding: 1px 3px;
  215. font-size: 10px;
  216. color: var(--text-inverse);
  217. }
  218. .meta-row {
  219. display: grid;
  220. grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  221. gap: 0.5rem;
  222. margin-top: 0.5rem;
  223. font-size: 0.75rem;
  224. color: var(--text-light);
  225. }
  226. .meta-item {
  227. display: flex;
  228. align-items: center;
  229. gap: 0.25rem;
  230. }
  231. .meta-label {
  232. font-weight: 500;
  233. }
  234. .meta-value {
  235. font-family: var(--font-mono);
  236. word-break: break-all;
  237. }
  238. .code-preview {
  239. position: relative;
  240. font-family: var(--font-mono);
  241. font-size: 0.875rem;
  242. background-color: #ffffff;
  243. padding: 0.5rem;
  244. border: 1px solid #808080;
  245. overflow-x: auto;
  246. margin-top: 0.5rem;
  247. white-space: pre-wrap;
  248. word-break: break-all;
  249. }
  250. .filters {
  251. margin-bottom: 12px;
  252. background-color: #c0c0c0;
  253. padding: 8px;
  254. border: 2px outset #d4d0c8;
  255. display: flex;
  256. gap: 1rem;
  257. flex-wrap: wrap;
  258. }
  259. .filter-group {
  260. display: flex;
  261. align-items: center;
  262. gap: 0.5rem;
  263. margin-bottom: 4px;
  264. }
  265. .filter-label {
  266. font-size: 12px;
  267. font-weight: normal;
  268. }
  269. .filter-input {
  270. background-color: #ffffff;
  271. border: 2px inset #d4d0c8;
  272. padding: 3px 4px;
  273. font-size: 12px;
  274. font-family: var(--font-main);
  275. }
  276. .app-footer {
  277. background-color: #c0c0c0;
  278. border-top: 2px outset #d4d0c8;
  279. font-size: 11px;
  280. padding: 3px 8px;
  281. height: 24px;
  282. display: flex;
  283. align-items: center;
  284. justify-content: space-between;
  285. flex-shrink: 0;
  286. }
  287. .description-toggle {
  288. cursor: pointer;
  289. color: var(--primary-color);
  290. font-size: 0.875rem;
  291. margin-left: 0.5rem;
  292. display: inline-flex;
  293. align-items: center;
  294. justify-content: center;
  295. width: 16px;
  296. height: 16px;
  297. background-color: #c0c0c0;
  298. border: 1px outset #d4d0c8;
  299. font-size: 10px;
  300. line-height: 14px;
  301. vertical-align: middle;
  302. }
  303. .description-toggle:hover {
  304. background-color: var(--primary-light);
  305. color: var(--text-inverse);
  306. }
  307. .description-expanded {
  308. white-space: normal;
  309. }
  310. .description-collapsed {
  311. white-space: nowrap;
  312. overflow: hidden;
  313. text-overflow: ellipsis;
  314. max-width: 250px;
  315. display: inline-block;
  316. }
  317. .commit-link {
  318. color: var(--primary-color);
  319. text-decoration: none;
  320. }
  321. .commit-link:hover {
  322. text-decoration: underline;
  323. }
  324. /* File path styling */
  325. .file-path-container {
  326. max-width: 100%;
  327. }
  328. .file-path {
  329. display: inline-block;
  330. max-width: 100%;
  331. word-wrap: break-word;
  332. word-break: break-all;
  333. }
  334. .match-content {
  335. font-family: var(--font-mono);
  336. font-size: 0.875rem;
  337. word-break: break-all;
  338. white-space: pre-wrap;
  339. display: block;
  340. background-color: #ffffff;
  341. border: 1px solid #808080;
  342. padding: 0.5rem;
  343. margin-top: 0.5rem;
  344. max-height: 300px;
  345. overflow-y: auto;
  346. }
  347. @media (max-width: 768px) {
  348. .app-header {
  349. padding: 0 1rem;
  350. }
  351. .app-main {
  352. padding: 1rem;
  353. }
  354. .report-stats {
  355. flex-direction: column;
  356. gap: 0.75rem;
  357. }
  358. .filters {
  359. flex-direction: column;
  360. gap: 0.75rem;
  361. }
  362. .app-footer {
  363. flex-direction: column;
  364. height: auto;
  365. padding: 0.75rem 1rem;
  366. gap: 0.5rem;
  367. justify-content: center;
  368. text-align: center;
  369. }
  370. }
  371. </style>
  372. </head>
  373. <body>
  374. <div class="app-container">
  375. <header class="app-header">
  376. <div class="logo">
  377. <h1>Gitleaks Security Findings</h1>
  378. </div>
  379. </header>
  380. <main class="app-main">
  381. <div class="report-info">
  382. <h2>Security Scan Report</h2>
  383. <p class="report-date">Generated on {{now | date "Jan 02, 2006 15:04:05 MST"}}</p>
  384. <div class="report-stats">
  385. <div class="stat-item">
  386. <span class="stat-value">{{len .}}</span>
  387. <span class="stat-label">Total Findings</span>
  388. </div>
  389. <div class="stat-item">
  390. <span class="stat-value" id="filesCount">-</span>
  391. <span class="stat-label">Files Affected</span>
  392. </div>
  393. <div class="stat-item">
  394. <span class="stat-value" id="rulesCount">-</span>
  395. <span class="stat-label">Unique Rules Triggered</span>
  396. </div>
  397. <div class="stat-item" id="scanModeContainer">
  398. <span class="stat-value" id="scanMode">-</span>
  399. <span class="stat-label">Scan Mode</span>
  400. </div>
  401. </div>
  402. </div>
  403. <div class="filters">
  404. <div class="filter-group">
  405. <label class="filter-label" for="filterRule">Filter by Rule:</label>
  406. <select class="filter-input" id="filterRule">
  407. <option value="all">All Rules</option>
  408. <!-- Rule options will be populated by JavaScript -->
  409. </select>
  410. </div>
  411. <div class="filter-group">
  412. <label class="filter-label" for="filterFile">Filter by File:</label>
  413. <input type="text" class="filter-input" id="filterFile" placeholder="Enter filename...">
  414. </div>
  415. <div class="filter-group">
  416. <button class="btn btn-primary btn-sm" id="resetFilters">Reset Filters</button>
  417. </div>
  418. </div>
  419. <div class="table-wrapper">
  420. <table class="findings-table" id="findingsTable">
  421. <thead>
  422. <tr>
  423. <th>Rule</th>
  424. <th>File</th>
  425. <th>Description</th>
  426. <th>Secret</th>
  427. <th>Metadata</th>
  428. </tr>
  429. </thead>
  430. <tbody>
  431. {{- range . }}
  432. <tr data-rule="{{.RuleID}}" data-file="{{.File}}">
  433. <td>{{.RuleID}}</td>
  434. <td>
  435. <div class="file-path-container">
  436. <span class="file-path" title="{{.File}}">{{.File}}</span>
  437. </div>
  438. <div class="tag-list">
  439. {{- range .Tags }}
  440. <span class="tag">{{.}}</span>
  441. {{- end}}
  442. </div>
  443. <div class="meta-row">
  444. <div class="meta-item">
  445. <span class="meta-label">Line:</span>
  446. <span class="meta-value">{{.StartLine}}</span>
  447. </div>
  448. </div>
  449. </td>
  450. <td>
  451. <span class="description-text">{{.Description}}</span>
  452. <span class="description-toggle" title="Expand/Collapse">↕</span>
  453. </td>
  454. <td>
  455. <div class="secret-container" data-secret="{{.Secret}}" data-match="{{.Match}}">
  456. <div class="secret-match">{{.Secret}}</div>
  457. <button type="button" class="match-toggle" title="Show/Hide Full Match Context">Show Context</button>
  458. <div class="match-content hidden" data-raw-match="{{.Match}}">{{.Match}}</div>
  459. </div>
  460. </td>
  461. <td>
  462. <div class="meta-row">
  463. <div class="meta-item">
  464. <span class="meta-label">Entropy:</span>
  465. <span class="meta-value">{{printf "%.2f" .Entropy}}</span>
  466. </div>
  467. {{- if .Commit}}
  468. <div class="meta-item commit-info">
  469. <span class="meta-label">Commit:</span>
  470. <span class="meta-value">{{if gt (len .Commit) 7}}{{printf "%.7s" .Commit}}{{else}}{{.Commit}}{{end}}</span>
  471. </div>
  472. {{- if .Author}}
  473. <div class="meta-item commit-info">
  474. <span class="meta-label">Author:</span>
  475. <span class="meta-value">{{.Author}}</span>
  476. </div>
  477. {{- end}}
  478. {{- if .Date}}
  479. <div class="meta-item commit-info">
  480. <span class="meta-label">Date:</span>
  481. <span class="meta-value">{{.Date}}</span>
  482. </div>
  483. {{- end}}
  484. {{- if .Link}}
  485. <div class="meta-item commit-info">
  486. <span class="meta-label">Link:</span>
  487. <span class="meta-value"><a href="{{.Link}}" target="_blank" class="commit-link">View Commit</a></span>
  488. </div>
  489. {{- end}}
  490. {{- else}}
  491. {{- if .Author}}
  492. <div class="meta-item">
  493. <span class="meta-label">Author:</span>
  494. <span class="meta-value">{{.Author}}</span>
  495. </div>
  496. {{- end}}
  497. {{- end}}
  498. </div>
  499. {{- if not .Match}}
  500. <div class="match-content" data-raw-match="">-</div>
  501. {{- end}}
  502. </td>
  503. </tr>
  504. {{- end }}
  505. </tbody>
  506. </table>
  507. </div>
  508. </main>
  509. <footer class="app-footer">
  510. <div>Generated by Gitleaks</div>
  511. <div>Total Findings: <strong>{{len .}}</strong></div>
  512. </footer>
  513. </div>
  514. <script>
  515. // Process data to collect unique files and rules
  516. function processData() {
  517. const rows = document.querySelectorAll('#findingsTable tbody tr');
  518. const uniqueRules = new Set();
  519. const uniqueFiles = new Set();
  520. let isGitMode = false;
  521. if (rows.length > 0) {
  522. // Check if first finding has commit data to determine mode
  523. const firstRow = rows[0];
  524. const commitCells = firstRow.querySelectorAll('.commit-info');
  525. isGitMode = commitCells.length > 0 && commitCells[0].textContent.trim() !== '';
  526. }
  527. // Set scan mode
  528. document.getElementById('scanMode').textContent = isGitMode ? 'Git' : 'Directory';
  529. // Adjust UI based on mode
  530. if (isGitMode) {
  531. // Ensure commit info columns are visible for git mode
  532. document.querySelectorAll('.commit-info').forEach(el => {
  533. el.style.display = 'block';
  534. });
  535. } else {
  536. // Hide commit-specific UI elements for directory mode
  537. document.querySelectorAll('.commit-info').forEach(el => {
  538. el.style.display = 'none';
  539. });
  540. }
  541. rows.forEach(row => {
  542. uniqueRules.add(row.dataset.rule);
  543. uniqueFiles.add(row.dataset.file);
  544. });
  545. // Update stats
  546. document.getElementById('filesCount').textContent = uniqueFiles.size;
  547. document.getElementById('rulesCount').textContent = uniqueRules.size;
  548. // Populate rule filter dropdown
  549. const ruleFilter = document.getElementById('filterRule');
  550. const sortedRules = Array.from(uniqueRules).sort();
  551. sortedRules.forEach(rule => {
  552. const option = document.createElement('option');
  553. option.value = rule;
  554. option.textContent = rule;
  555. ruleFilter.appendChild(option);
  556. });
  557. }
  558. // Hide toggle button if match is same as secret
  559. function hideRedundantToggleButtons() {
  560. document.querySelectorAll('.secret-container').forEach(container => {
  561. const secret = container.getAttribute('data-secret');
  562. const match = container.getAttribute('data-match');
  563. const toggleButton = container.querySelector('.match-toggle');
  564. // If secret and match are the same, or if match is empty, hide the toggle button
  565. if ((secret && match && secret.trim() === match.trim()) || !match) {
  566. if (toggleButton) {
  567. toggleButton.style.display = 'none';
  568. }
  569. }
  570. });
  571. }
  572. // Setup toggle buttons
  573. function setupToggleButtons() {
  574. document.querySelectorAll('.match-toggle').forEach(btn => {
  575. btn.addEventListener('click', function() {
  576. const matchContent = this.nextElementSibling;
  577. if (matchContent.classList.contains('hidden')) {
  578. matchContent.classList.remove('hidden');
  579. this.textContent = 'Hide Context';
  580. } else {
  581. matchContent.classList.add('hidden');
  582. this.textContent = 'Show Context';
  583. }
  584. });
  585. });
  586. // Setup description toggle
  587. document.querySelectorAll('.description-text').forEach(descriptionText => {
  588. const toggleBtn = descriptionText.nextElementSibling;
  589. if (!toggleBtn || !toggleBtn.classList.contains('description-toggle')) return;
  590. // Initial state: collapsed
  591. descriptionText.classList.add('description-collapsed');
  592. toggleBtn.addEventListener('click', () => {
  593. if (descriptionText.classList.contains('description-collapsed')) {
  594. descriptionText.classList.remove('description-collapsed');
  595. descriptionText.classList.add('description-expanded');
  596. toggleBtn.textContent = '↑';
  597. } else {
  598. descriptionText.classList.remove('description-expanded');
  599. descriptionText.classList.add('description-collapsed');
  600. toggleBtn.textContent = '↕';
  601. }
  602. });
  603. });
  604. }
  605. // Filter functionality
  606. function applyFilters() {
  607. const ruleFilter = document.getElementById('filterRule').value;
  608. const fileFilter = document.getElementById('filterFile').value.toLowerCase();
  609. const rows = document.querySelectorAll('#findingsTable tbody tr');
  610. rows.forEach(row => {
  611. const ruleMatch = ruleFilter === 'all' || row.dataset.rule === ruleFilter;
  612. const fileMatch = fileFilter === '' || row.dataset.file.toLowerCase().includes(fileFilter);
  613. if (ruleMatch && fileMatch) {
  614. row.style.display = '';
  615. } else {
  616. row.style.display = 'none';
  617. }
  618. });
  619. // Update visible count
  620. const visibleFindings = document.querySelectorAll('#findingsTable tbody tr:not([style*="display: none"])').length;
  621. document.querySelector('.app-footer strong').textContent = visibleFindings;
  622. }
  623. document.getElementById('filterRule').addEventListener('change', applyFilters);
  624. document.getElementById('filterFile').addEventListener('input', applyFilters);
  625. document.getElementById('resetFilters').addEventListener('click', function() {
  626. document.getElementById('filterRule').value = 'all';
  627. document.getElementById('filterFile').value = '';
  628. applyFilters();
  629. });
  630. // Initialize
  631. document.addEventListener('DOMContentLoaded', function() {
  632. processData();
  633. hideRedundantToggleButtons(); // Hide toggle buttons for matching secrets
  634. setupToggleButtons();
  635. });
  636. </script>
  637. </body>
  638. </html>