Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Parse JSON Configs for Insecure Defaults

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

Your question is Parse JSON Configs for Insecure Defaults. 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

PayPal Checkout configuration is represented as nested JSON objects and arrays. Given a configuration and a set of security rules, find every configured path whose value matches an insecure default.

Each rule uses a dotted path, such as checkout.security.tls_enabled, and maps to a list of insecure JSON values. A path segment containing * matches exactly one object key or array index, allowing a rule such as merchants.*.logging.debug to apply to every merchant. Return findings sorted lexicographically by their concrete dotted path.

Formal Specification

Implement detect_insecure_defaults(config, rules).

  • config is a JSON-compatible Python value composed of dictionaries, lists, strings, numbers, booleans, and None.
  • rules is a dictionary mapping dotted rule paths to lists of insecure JSON values.
  • The result is a list of dictionaries with keys path and value.
  • Report a finding when a rule matches a concrete path and its value equals one of that rule's insecure values.
  • Traverse nested objects and arrays. Array indices are path segments such as 0.

Constraints

  • 1 <= total JSON nodes <= 10^4
  • 1 <= len(rules) <= 10^3
  • Maximum nesting depth is 100
  • Rule paths are non-empty and use '.' as the separator
  • Each wildcard matches exactly one path segment

Function Signature

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