Frontend - Display badges on Dependency Lists
TL;DR
Show a "Malware" badge on dependencies flagged as malware packages.
Acceptance Criteria
- Badge with text "Malware" displayed for malware dependencies
- Badge appears in the Risk/Vulnerabilities column alongside vulnerability count
- Badge has tooltip: "This package has been identified as malware"
- Works on project-level Dependency List (
/project/-/dependencies) - Works on group-level Dependency List (
/group/-/dependencies) - Behind feature flag
malicious_package_badges - When flag disabled, no badge shown (existing behavior)
Implementation Details
GraphQL Field Availability
The malware field may not be available on all GitLab instances immediately. Use the @gl_introduced directive for graceful degradation:
malware @gl_introducedNotes:
- Executable directives don't support arguments
- For fragments, use the directive in the fragment nodes
See GraphQL style guide - Mitigation.
Files to Modify
ee/app/assets/javascripts/dependencies/components/- Add badge rendering to dependency list item and vulnerabilities componentsee/app/assets/javascripts/dependencies/graphql/dependencies.query.graphql- Addmalwarefield to queryee/app/assets/javascripts/dependencies/constants.js- Add i18n strings for badge text and tooltip
Implementation Approach
- Update GraphQL query to request the
malwarefield from the dependencies query - Add badge component using
GlBadgewithvariant="danger"andsize="sm" - Conditional rendering based on
dependency.malwareAND feature flagglFeatures.maliciousPackageBadges - Add tooltip using
v-gl-tooltipdirective with appropriate message - Add i18n strings for "Malware" badge text and tooltip message
Testing Approach
- Component tests: badge renders when
malware: true - Component tests: badge hidden when
malware: false - Component tests: badge hidden when feature flag disabled
- Add malicious dependency to mock data
Estimate
/estimate 24h
Dependencies
- Blocked by: Backend - Expose malware status in APIs
- Parent: Display Malicious Package Information
Edited by David Pisek