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

edit DNS grammar #3768

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

edit DNS grammar #3768

wants to merge 5 commits into from

Conversation

Checconio
Copy link
Contributor

add support for character strings and modification of DNS registration type recognition

Changes

add
{
// Character strings
scope: 'string',
begin: '"', end: '"'
},
{
className: 'type',
begin: /IN|CH/
}

edit KEYWORDS

Checklist

  • [ X] Added markup tests, or they don't apply here because...
  • [ X] Updated the changelog at CHANGES.md

@joshgoebel
Copy link
Member

joshgoebel commented Apr 27, 2023

Please show us an example of this syntax in an actual DNS file. Any how did we decide IN and CH are types?

@Checconio
Copy link
Contributor Author

Hello,

The current syntax detects comments in values that are strings, which is a bug.

Here is the overview of the current syntax
actualdns

In my syntax I add support for character strings to fix the comment bug in DNS values

In the current file, the keywords are the DNS record names, which is not the case for the "IN" and "CH" values which correspond to the class of the DNS record.
That's why I wanted to separate them.

Here is the result of my changes
newdns

src/languages/dns.js Outdated Show resolved Hide resolved
{
className: 'meta',
begin: /^\$(TTL|GENERATE|INCLUDE|ORIGIN)\b/
},
{
className: 'type',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scope

{
className: 'meta',
begin: /^\$(TTL|GENERATE|INCLUDE|ORIGIN)\b/
},
{
className: 'type',
begin: /IN|CH/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

match

@joshgoebel
Copy link
Member

In my syntax I add support for character strings to fix the comment bug in DNS values

Yep. Nice. If you wanted to push further why not highlight everything following TXT as a string, quoted or not? This would prevent the other false positives we are seeing of random highlighting inside those strings.

In the current file, the keywords are the DNS record names, which is not the case for the "IN" and "CH" values which correspond to the class of the DNS record.

Makes sense.

Scoping () as punctuation might be nice as well.

Copy link
Member

@joshgoebel joshgoebel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few suggestions/changes above.

@Checconio
Copy link
Contributor Author

I made the corrections and we now have a file that looks good :)
dns

@joshgoebel
Copy link
Member

Please provide your test content here in textual form.

@Checconio
Copy link
Contributor Author

Please provide your test content here in textual form.

;
; BIND data file for local loopback interface
;
$TTL    3600
$ORIGIN checconio.fr.
$INCLUDE "Kchecconio.fr.zsk.key"
$INCLUDE "Kchecconio.fr.ksk.key"

@       IN      SOA     server.dorianchecconi.fr. root.dorianchecconi.fr. (
                        2023040124      ; Serial
                        1200            ; Refresh
                        120             ; Retry
                        604800          ; Expire
                        3600 )  ; Negative Cache TTL

@               IN      NS      server.dorianchecconi.fr.

@               IN      CAA     0       issue   "letsencrypt.org"

@               IN      MX      10      server.dorianchecconi.fr.

@               IN      TXT     google-site-verification=aU4dDNsp6XuXfh2-3cTTU4
@               IN      TXT     brave-ledger-verification=807e569d632d84c67b73c1847321ce63c6f35be9a1ca
@               IN      TXT     "v=spf1 a mx ip4:80.31.156.3 ~all"
_dmarc          IN      TXT     "v=DMARC1;p=reject;pct=100;ruf=mailto:admin@checconio.fr;rua=mailto:postmaster@checconio.fr;sp=reject;adkim=s;aspf=s;rf=afrf;fo=1"
_domainkey      IN      TXT     "o=-; r=postmaster@checconio.fr"
mail._domainkey IN      TXT     ( "v=DKIM1; h=sha256; k=rsa; ""p=MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICoeVFwlbm1MB3ax4vQTB9Sk0llRKIuWxuidRG/h74PdwNf3iSyA9UxeRZPR0qZOChSoWvXQKGAyWmwrRQQoqmzUTp9xaHPra6+ds+quSvzWLZBLI3iulGu1X6QcehfTNfsnJkCLIxnxh""sm8AME8WzmxVL48xQSx6BhrOh6iz1U9EEPB0+5q5aV0iY0VvzJsm0fcTZ9GtVGoJCzcVORZgedY5R7WYeVkEDecX8teAiFNZihigwfdN3XemBwcl2U+eGmUgqeeHSJaJ36ooKnnUq7zB+w4dHWmJYo7yN5VdPeDVyTE/KwB+PoRCNfhe2/VGfSso0jsi+azp5bBfj6EFYxcyDtaLeoDUjK+v/qqPH76MUjcvA9/P7J4UxoNZcaP3laszB9""G/s/krbY7em3qjKrdW4IAqlaEAb6H4KskR1W0rBz4RdjOmP6XsoygL2Z2Q7uglT4lpEJYWk12FuV7k3F0AiXtKdlMduCb2wQGsOlh2ZE4oaEqRvwJEPvZyI8wyEF3QN27buYbX6GnMC+X8x1TfzcUTnKxzZX2Q0X5b2JVaLEvmd+VipcA6FtLSfR8AFikzB9X/9EJxHYm4vc48kOLhhGlVsLbzw5Ygz09ScCAwEAAQ==" )
_smtp._tls              IN      TXT     "v=TLSRPTv1;rua=mailto:postmaster@checconio.fr"

;_autodiscover._tcp     IN      SRV     10      10      443 autodiscover.checconio.fr.

@               IN      A       80.31.156.3
autodiscover    IN      A       82.11.196.30

@Checconio
Copy link
Contributor Author

test content

The test content is good ?

@Checconio
Copy link
Contributor Author

joshgoebel Have you news for this change ?

Thank's

@joshgoebel
Copy link
Member

Please pull down my latest commit and test. It tries to more accurately handle TXT records. You might have to -f since I rebased. If it looks good and you could make sure the tests are back in sync then I think this is good to ship.

@Checconio Checconio requested a review from joshgoebel May 26, 2023 09:59
Copy link
Contributor Author

@Checconio Checconio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add

@Checconio
Copy link
Contributor Author

Please pull down my latest commit and test. It tries to more accurately handle TXT records. You might have to -f since I rebased. If it looks good and you could make sure the tests are back in sync then I think this is good to ship.

Thank you for these modifications I have just tested and confirm that everything is good!

@Checconio
Copy link
Contributor Author

joshgoebel It's good for you ?

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.

None yet

2 participants