Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare snapshots ignores properties when dicts have different levels #108

Closed
alperenkose opened this issue Aug 8, 2023 · 0 comments · Fixed by #128
Closed

Compare snapshots ignores properties when dicts have different levels #108

alperenkose opened this issue Aug 8, 2023 · 0 comments · Fixed by #128
Assignees
Labels
bug Something isn't working

Comments

@alperenkose
Copy link
Collaborator

Describe the bug

Issue is identified on a case in License comparison, when one of the licenses ("Logging Service") had an extra sub-dictionary ("custom") and randomly occurred since properties are checked at the lowest level in json and a random key is checked within the next level whether it's dictionary or not to identify if we are at the lowest level in order to process the passed properties. When the check is done on the "custom" key, it went further on the nested dict and produced a diff even it was set to skip serial and issued elements.

See following example:
Requested config: ["!serial", "!issued"]

Left side dictionary:

{
  "license": {
    "Logging Service": {
      "authcode": null,
      "custom": {
        "_Log_Storage_TB": "7"
      },
      "description": "Device Logging Service",
      "expired": "no",
      "expires": "August 04, 2024",
      "feature": "Logging Service",
      "issued": "June 27, 2022",
      "serial": "11111111"
    },
    "PAN-DB URL Filtering": {
      "authcode": null,
      "description": "Palo Alto Networks URL Filtering License",
      "expired": "no",
      "expires": "June 30, 2028",
      "feature": "PAN-DB URL Filtering",
      "issued": "April 29, 2023",
      "serial": "11111111"
    }
  }
}

Right side dictionary:

{
  "license": {
    "Logging Service": {
      "authcode": null,
      "custom": {
        "_Log_Storage_TB": "8"
      },
      "description": "Device Logging Service",
      "expired": "no",
      "expires": "August 04, 2024",
      "feature": "Logging Service",
      "issued": "June 29, 2022",
      "serial": "22222222"
    },
    "PAN-DB URL Filtering": {
      "authcode": null,
      "description": "Palo Alto Networks URL Filtering License",
      "expired": "no",
      "expires": "June 30, 2028",
      "feature": "PAN-DB URL Filtering",
      "issued": "April 29, 2023",
      "serial": "22222222"
    }
  }
}
$ python snapshot_load_compare.py
 license:
   | passed: False
   | missing:
   |   | passed: True
   | added:
   |   | passed: True
   | changed:
   |   | passed: False
   |   | changed_raw:
   |   |   | Logging Service:
   |   |   |   | passed: False
   |   |   |   | missing:
   |   |   |   |   | passed: True
   |   |   |   | added:
   |   |   |   |   | passed: True
   |   |   |   | changed:
   |   |   |   |   | passed: False
   |   |   |   |   | changed_raw:
   |   |   |   |   |   | serial:
   |   |   |   |   |   |   | left_snap: 11111111
   |   |   |   |   |   |   | right_snap: 22222222
   |   |   |   |   |   | issued:
   |   |   |   |   |   |   | left_snap: June 27, 2022
   |   |   |   |   |   |   | right_snap: June 29, 2022

Possible solution

Instead of checking if we are at the lowest level in order to process the passed properties (requested configuration), we can check if these exist on any level we are parsing, so the requested configuration can be applied on any level. This will require ignoring non-relevant requested configurations for a level on ConfigParser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant