Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Basics of Secure Code Review

Basics of Secure Code Review

Avatar for fadzayi chiwandire

fadzayi chiwandire

August 15, 2022

Other Decks in Technology

Transcript

  1. Checklist https://github.com/mgreiler/secure-code-review-checklist • Input Validation • Authentication and User Management

    • Authorization • Session Management • Encryption & Cryptography • Exception Handling • Reducing the attack surface
  2. RegEx export const isPasswordValid = validationMessage => value => (

    /^([a-zA-Z0-9!@#$%^&*_\-.()]{13,64})$/ .test(value) ? undefined : validationMessage || 'Password is invalid' )
  3. Unit Tests // must contain at least one: digit, lower

    case, Upper case, special character and be >=8 describe('isPasswordValid()', () => { test('Returns undefined if password is correctly formatted, error message otherwise', () => { expect(isPasswordValid('Password invalid')('12345678')).toBe('Password invalid') expect(isPasswordValid('Password invalid')('aaaaaaaa')).toBe('Password invalid') expect(isPasswordValid('Password invalid')('ABCDEFGH')).toBe('Password invalid') expect(isPasswordValid('Password invalid')('123Abcde')).toBe('Password invalid') expect(isPasswordValid('Password invalid')('12@Ab')).toBe('Password invalid') expect(isPasswordValid('Password invalid')('12@Abcde')).toBe('Password invalid') expect(isPasswordValid('Password invalid')('12@Abcdepoiuy')).toBe(undefined) }) })
  4. Tools • Snyk • Semgrep • Insider • OWASP Dependency-Check

    • TruffleHog (Secret Scanner) • Brakeman (Ruby on Rails) REDACTED Snyk Semgrep