Dependency Vulnerabilities — Security

Risiko Dependencies Aplikasi modern menggunakan ratusan dependencies. Setiap dependency adalah kode yang ditulis orang lain yang kita percaya untuk berjalan di

Risiko Dependencies

Aplikasi modern menggunakan ratusan dependencies. Setiap dependency adalah kode yang ditulis orang lain yang kita percaya untuk berjalan di sistem kita. Satu vulnerability di satu dependency bisa mempengaruhi jutaan aplikasi.

Contoh Insiden Terkenal

Mendeteksi Vulnerability

1. npm audit

# Cek vulnerability di Node.js dependencies
npm audit

# Output menunjukkan severity dan fix yang tersedia
# Fix otomatis
npm audit fix

# Fix yang memerlukan major version update
npm audit fix --force  # Hati-hati, bisa break code

2. Composer audit (PHP)

# Cek vulnerability di PHP dependencies
composer audit

# Update dependencies
composer update --with-all-dependencies

3. GitHub Dependabot

# .github/dependabot.yml
version: 2
updates:
  - package-ecosystem: "npm"
    directory: "/"
    schedule:
      interval: "weekly"
    open-pull-requests-limit: 10
  - package-ecosystem: "composer"
    directory: "/"
    schedule:
      interval: "weekly"

4. Snyk

# Install Snyk CLI
npm install -g snyk

# Test dependencies
snyk test

# Monitor secara continuous
snyk monitor

Strategi Pengelolaan Dependencies

Lockfile Security

# Selalu commit lockfile
git add package-lock.json  # atau composer.lock

# Di CI/CD, gunakan ci install (bukan install)
npm ci       # Strict install dari lockfile
composer install --no-dev  # Production install

Best Practices

Yang akan kamu pelajari