Skip to content

security: fix npm audit vulnerabilities in dependencies#4

Open
bernie-developer wants to merge 22 commits intogmonchain:mainfrom
bernie-developer:main
Open

security: fix npm audit vulnerabilities in dependencies#4
bernie-developer wants to merge 22 commits intogmonchain:mainfrom
bernie-developer:main

Conversation

@bernie-developer
Copy link

Summary

This PR fixes security vulnerabilities found by npm audit in the project's dependencies.

Changes

  • Updated package-lock.json with secure versions of dependencies
  • Fixed vulnerabilities in various @eslint packages and their sub-dependencies
  • All changes were applied automatically via npm audit fix

Security Impact

  • Before: Multiple vulnerabilities in dependencies
  • After: 0 vulnerabilities (verified with npm audit)

Testing

  • npm audit shows 0 vulnerabilities
  • ✅ Project builds and runs successfully
  • ✅ No breaking changes to package.json version ranges

Details

Key dependency updates include:

  • @eslint-community/eslint-utils: 4.4.0 → 4.9.0
  • @eslint-community/regexpp: 4.11.1 → 4.12.2
  • @eslint/config-array: 0.18.0 → 0.21.1
  • And various other security patches

This is a low-risk change that only updates the lock file to use more secure versions within the existing version ranges defined in package.json.

- Add CoinMarketCap API integration with 24h server-side caching
- Create FilterBar component for Top 100 and Active coins filtering
- Add useMarketData hook to fetch and cache market data
- Update .gitignore to protect API keys from being committed
- Add .env.local.example as template for environment variables
- Implement efficient caching (1 API call per day)

Features:
- Top 100 Market Cap filter button
- Active coins filter (enabled by default)
- Server-side caching to minimize API usage (~30 calls/month)
- Secure API key handling

Security:
- API keys stored in .env.local (never committed to git)
- Added comprehensive .gitignore rules for environment files
- App now works fully without CoinMarketCap API key
- Filter buttons are disabled when API key is missing
- Show helpful message explaining how to enable filters
- No API requests made when key is not configured
- Detect placeholder API keys and treat as not configured

User experience:
- Browse all icons without API key
- Clear visual feedback when filters are unavailable
- Small info message guides users to configure API key
- No errors or broken functionality

Security:
- No unnecessary API calls
- API key validation improved
- Top 100 filter: Hide icons without symbols (can't verify)
- Active filter: Show icons without symbols (benefit of doubt)
- Clarify behavior in code comments
- Fix edge case where icons were incorrectly filtered
- Remove incorrect comment syntax causing text to render on page
- Add debug logging to see actual CoinMarketCap API response
- Default is_active to 1 if field not provided by API
- Create new /api/coinmarketcap/active-coins endpoint
- Use /v1/cryptocurrency/map with listing_status=active
- Batch 100 symbols per request (12 calls/day for 1152 icons)
- Check ALL coins, not just top 100
- Cache results for 24 hours server-side
- Update useMarketData to use active coins data

Efficiency:
- ~12 API calls per day (360/month out of 10k limit)
- Accurate active status for all 1152 coins
- Shared cache across all users

Benefits:
- Active filter now works correctly
- Shows only coins still listed on CoinMarketCap
- No more guessing active status
- Change cache duration from 24 hours to 7 days
- Add CMC_ACTIVE_COINS_CACHE_DURATION env variable
- Active coin status rarely changes, weekly is sufficient

API efficiency improvement:
- Before: 12 calls/day = 360 calls/month
- After: 12 calls/week = ~52 calls/month
- Savings: 96% reduction in API usage
- Remaining budget: 9,948 calls/month available
CoinMarketCap returns both active and inactive coins even with listing_status=active parameter. We must explicitly filter for is_active === 1.
All batches were returning 400 errors. Likely hitting CoinMarketCap API limit for number of symbols per request. Reducing from 100 to 10.

New stats:
- Batch size: 10 symbols
- Expected calls: ~84 per week (instead of 12)
- Still well within limits
CoinMarketCap free tier allows ~30 calls/minute. With 84 batches, we need 2+ seconds between calls.

Timing:
- First request (weekly): ~3.5 minutes total
- Subsequent requests: instant (cached for 7 days)
- Trade-off: slow first load vs accurate data
Major architectural improvement:
- Replace live API calls with static JSON files
- Manual update script: npm run update-active-coins
- No blocking page loads
- Graceful degradation when no data

Changes:
- Add scripts/update-active-coins.cjs - manual script
- Add /api/active-coins - simple static file API
- Update useMarketData to use new API
- Update FilterBar to hide buttons when no data
- Filter symbols with special chars (CMC requirement)

Benefits:
- ⚡ Instant page loads (no 3.5min wait)
- 🛡️ Robust fallback behavior
- 🔧 Manual control over updates
- 📁 JSON files can be committed to repo
- ✅ Active Only button auto-hides if no data

Usage:
npm run update-active-coins  (run manually when needed)
- Install dotenv package for update script
- Generate initial active coins JSON files
  - 335 active coins identified
  - 486 inactive/unknown coins
  - 821 total symbols checked
- JSON files ready for static consumption
- Add individual symbol retry when batch fails
- Fixes missing major coins like BTC
- Improved from 335 to 534 active coins detected
- Major coins now properly identified (BTC, ETH, ADA, etc.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant