Skip to content

Fix configparser interpolation error#5

Merged
wilfried-becard merged 1 commit intosynacktiv:mainfrom
Darktortue:fix-configparser-error
Mar 11, 2026
Merged

Fix configparser interpolation error#5
wilfried-becard merged 1 commit intosynacktiv:mainfrom
Darktortue:fix-configparser-error

Conversation

@Darktortue
Copy link
Copy Markdown
Contributor

@Darktortue Darktortue commented Feb 12, 2026

It seems that if some special characters are found in a policy (for example %), the script stops as it faces an error due to Configparser interpolation logic:

Retrieving \domain.local\Policies\{ABCD1234-61AC-48FC-9A47-6BA65FFD14FD}\User/Preferences/Groups/Groups.xml
Retrieving \domain.local\Policies\{ABCD1234-61AC-48FC-9A47-6BA65FFD14FD}\User/Preferences/Registry/Registry.xml
Traceback (most recent call last):
  File "/home/darktortue/.local/bin/gpoParser", line 7, in <module>
    sys.exit(main())
             ~~~~^^
  File "/home/darktortue/.local/share/pipx/venvs/gpoparser/lib/python3.13/site-packages/gpoParser/__init__.py", line 66, in main
    parse_sysvol_content(gpo_objects)
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/home/darktortue/.local/share/pipx/venvs/gpoparser/lib/python3.13/site-packages/gpoParser/core/sysvol.py", line 172, in parse_sysvol_content
    parse_gpttmpl(gpo_objects)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "/home/darktortue/.local/share/pipx/venvs/gpoparser/lib/python3.13/site-packages/gpoParser/core/sysvol.py", line 217, in parse_gpttmpl
    for item in config.items("Registry Values"):
                ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/configparser.py", line 890, in items
    return [(option, value_getter(option)) for option in orig_keys]
                     ~~~~~~~~~~~~^^^^^^^^
  File "/usr/lib/python3.13/configparser.py", line 886, in <lambda>
    value_getter = lambda option: self._interpolation.before_get(self,
                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
        section, option, d[option], d)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/configparser.py", line 415, in before_get
    self._interpolate_some(parser, option, L, value, section, defaults, 1)
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/configparser.py", line 462, in _interpolate_some
    raise InterpolationSyntaxError(
    ...<2 lines>...
        "found: %r" % (rest,))

configparser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found: '%*<>&#\'{([-|`_\\^ @)]}!:/"'

Interpolation needs to be disabled to prevent the error.

config = CaseSensitiveConfigParser(allow_no_value=True, strict=False, interpolation=None)

@wilfried-becard wilfried-becard merged commit 2f5acb2 into synacktiv:main Mar 11, 2026
@wilfried-becard
Copy link
Copy Markdown
Collaborator

Thank you for the PR ! Appreciate it !

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.

2 participants