Skip to content
Snippets Groups Projects
Select Git revision
  • 94e8af35bb4ead2567d5db4675ac9a3a24d332e8
  • main default protected
  • dependabot/go_modules/k8s.io/client-go-0.33.4
  • dependabot/go_modules/k8s.io/apimachinery-0.33.4
  • automated-updates-main
  • release-0.14
  • 14-env
  • fix-version-3
  • automated-updates-fix-action
  • release-0.15
  • release-0.13
  • automated-updates-release-0.13
  • release-0.10
  • release-0.11
  • release-0.12
  • fix-versions-action
  • versions-fix
  • release-0.9
  • release-0.8
  • release-0.7
  • release-0.6
  • v0.15.0
  • v0.14.0
  • v0.13.0
  • v0.12.0
  • v0.11.0
  • v0.10.0
  • v0.9.0
  • v0.8.0
  • v0.7.0
  • v0.6.0
  • v0.5.0
  • v0.4.0
  • v0.3.0
  • v0.2.0
  • v0.1.0
36 results

exposing-prometheus-alertmanager-grafana-ingress.md

Blame
  • sanitize.spec.ts 1.42 KiB
    import {
      addSecretForSanitizing,
      clearGlobalSanitizedSecretsList,
      clearRepoSanitizedSecretsList,
      sanitize,
    } from './sanitize';
    import { toBase64 } from './string';
    
    describe('util/sanitize', () => {
      beforeEach(() => {
        clearRepoSanitizedSecretsList();
        clearGlobalSanitizedSecretsList();
      });
    
      it('sanitizes empty string', () => {
        addSecretForSanitizing('');
        expect(sanitize(null as never)).toBeNull();
        expect(sanitize('')).toBe('');
      });
    
      it('sanitizes secrets from strings', () => {
        const token = '123testtoken';
        const username = 'userabc';
        const password = 'password123';
        addSecretForSanitizing(token, 'global');
        const hashed = toBase64(`${username}:${password}`);
        addSecretForSanitizing(hashed);
        addSecretForSanitizing(password);
    
        const input = `My token is ${token}, username is "${username}" and password is "${password}" (hashed: ${hashed})`;
        const output =
          'My token is **redacted**, username is "userabc" and password is "**redacted**" (hashed: **redacted**)';
        expect(sanitize(input)).toBe(output);
    
        const inputX2 = [input, input].join('\n');
        const outputX2 = [output, output].join('\n');
        expect(sanitize(inputX2)).toBe(outputX2);
      });
    
      it('sanitizes github app tokens', () => {
        addSecretForSanitizing('x-access-token:abc123');
        expect(sanitize(`hello ${toBase64('abc123')} world`)).toBe(
          'hello **redacted** world',
        );
      });
    });