Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Identify Vulnerable Dependencies

MediumPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Identify Vulnerable Dependencies. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Write a function to identify vulnerable dependencies in a mock file system.

The mock file system is a dictionary mapping file paths to manifest contents. Each nonblank, noncomment line has the form package==version. An advisory database maps package names to inclusive vulnerable version intervals. Return sorted package names that appear in any manifest with a version covered by at least one advisory interval.

Signature: def find_vulnerable_dependencies(files, advisories):

Versions contain dot-separated nonnegative integers. Ignore packages absent from the advisory database. Duplicate declarations should appear once in the result.

Constraints

  • 1 <= len(files) <= 5,000
  • Each manifest contains valid dependency lines, blank lines, or comments beginning with '#'
  • Each dependency line contains exactly one package name and version separated by '=='
  • Package names are nonempty strings
  • Versions contain 1 to 4 nonnegative integer components
  • Advisory intervals are inclusive and have lower <= upper
  • The total number of dependency declarations and advisory intervals is at most 100,000

Function Signature

def find_vulnerable_dependencies(files, advisories):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output