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

Fix for CAA Records #15

Merged
merged 1 commit into from
Dec 4, 2020
Merged

Fix for CAA Records #15

merged 1 commit into from
Dec 4, 2020

Conversation

GeertHauwaerts
Copy link
Contributor

The API returns the data as space separated, not tab separated.

The API returns the data as space separated, not tab separated.
@bobrik
Copy link
Contributor

bobrik commented Oct 9, 2020

cc @jpmsilva, @t2b, since you touched this before.

@jpmsilva
Copy link
Contributor

jpmsilva commented Dec 3, 2020

Apologies for the delay.

I tried the patch provided and I got this error:

          ID: vilt-group.com
    Function: cloudflare.manage_zone_records
      Result: False
     Comment: An exception occurred in this state: Traceback (most recent call last):
                File "/var/cache/salt/minion/extmods/states/cloudflare.py", line 342, in sanity_check
                  record.data()
                File "/var/cache/salt/minion/extmods/states/cloudflare.py", line 191, in data
                  flags, tag, value = parts
              ValueError: not enough values to unpack (expected 3, got 1)

              During handling of the above exception, another exception occurred:

              Traceback (most recent call last):
                File "/usr/lib/python3/dist-packages/salt/state.py", line 2154, in call
                  *cdata["args"], **cdata["kwargs"]
                File "/usr/lib/python3/dist-packages/salt/loader.py", line 2106, in wrapper
                  return f(*args, **kwargs)
                File "/var/cache/salt/minion/extmods/states/cloudflare.py", line 73, in manage_zone_records
                  managed.sanity_check()
                File "/var/cache/salt/minion/extmods/states/cloudflare.py", line 346, in sanity_check
                  str(record), e
              Exception: Record CAA vilt-group.com -> '0        issuewild       "comodoca.com"' (proxied: , ttl: false) cannot synthesize data from content: not enough values to unpack (expected 3, got 1)
     Started: 15:45:55.948183
    Duration: 914.825 ms

The record I get back from Cloudflare's API shows me spaces (multiple) separating each field:

0        issuewild       "comodoca.com"

@GeertHauwaerts what error were you getting before this fix?

@jpmsilva
Copy link
Contributor

jpmsilva commented Dec 3, 2020

So I debugged a bit more what was happening, and the error I saw was due to having the pillar data with tabs.
I don't know for sure, but perhaps at some point the API changed tabs to spaces, as this used to work fine with tabs.

Anyway after applying this MR and updating the pillar data, the patch works as intended.
I can also confirm the initial statement that the API returns space separated data.
I think that the observed behavior of the saltstack module without the patch is that if I run a state.apply with test=True, there are always changes detected in the CAA records. This is due to the diff code detecting tabs vs spaces changes.

So all in all I think that this patch should be merged.

@t2b
Copy link
Contributor

t2b commented Dec 4, 2020

I come to the same conclusion as jpmsilva. the current version of the code does not work anymore. the changes in this pull-request and replacing \t (tabs) with (whitespaces) in the values of CAA records in the pillars fixes the problem.
The pull-request can be merged.

@bobrik bobrik merged commit 92b8a5d into cloudflare:master Dec 4, 2020
@bobrik
Copy link
Contributor

bobrik commented Dec 4, 2020

Thanks, all!

@GeertHauwaerts GeertHauwaerts deleted the patch-1 branch December 6, 2020 22:07
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.

4 participants