fix trailing dot (#4295)

* fix trailing dot

* remove trailing dot from `domain`

* remove trailing dots from answer

* remove dots

* fix integration test
This commit is contained in:
Dogan Can Bakir 2023-11-01 14:21:22 +03:00 committed by GitHub
parent 8371223af1
commit c79d2f05c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 7 additions and 6 deletions

View File

@ -13,7 +13,7 @@ dns:
- type: dsl
name: blogid
dsl:
- trim_suffix(cname,'.ghost.io.')
- trim_suffix(cname,'.ghost.io')
internal: true
http:

View File

@ -7,7 +7,7 @@ info:
variables:
cname_filtered: '{{trim_suffix(dns_cname,".ghost.io.")}}'
cname_filtered: '{{trim_suffix(dns_cname,".ghost.io")}}'
dns:
- name: "{{FQDN}}" # DNS Request

View File

@ -21,6 +21,6 @@ http:
- type: dsl
dsl:
- contains(http_body,'ProjectDiscovery.io') # check for http string
- trim_suffix(dns_cname,'.ghost.io.') == 'projectdiscovery' # check for cname (extracted information from dns response)
- trim_suffix(dns_cname,'.ghost.io') == 'projectdiscovery' # check for cname (extracted information from dns response)
- ssl_subject_cn == 'blog.projectdiscovery.io'
condition: and

View File

@ -159,7 +159,7 @@ func recordsKeyValue(resourceRecords []dns.RR) output.InternalEvent {
var oe = make(output.InternalEvent)
for _, resourceRecord := range resourceRecords {
key := strings.ToLower(dns.TypeToString[resourceRecord.Header().Rrtype])
value := strings.ReplaceAll(resourceRecord.String(), resourceRecord.Header().String(), "")
value := strings.TrimSuffix(strings.ReplaceAll(resourceRecord.String(), resourceRecord.Header().String(), ""), ".")
// if the key is already present, we need to convert the value to a slice
// if the key has slice, then append the value to the slice

View File

@ -103,6 +103,7 @@ func (request *Request) execute(input *contextargs.Context, domain string, metad
question = compiledRequest.Question[0].Name
}
// remove the last dot
domain = strings.TrimSuffix(domain, ".")
question = strings.TrimSuffix(question, ".")
requestString := compiledRequest.String()

View File

@ -13,7 +13,7 @@ dns:
- type: dsl
name: blogid
dsl:
- trim_suffix(cname,'.ghost.io.')
- trim_suffix(cname,'.ghost.io')
internal: true

View File

@ -21,6 +21,6 @@ http:
- type: dsl
dsl:
- contains(http_body,'ProjectDiscovery.io') # check for http string
- trim_suffix(dns_cname,'.ghost.io.') == 'projectdiscovery' # check for cname (extracted information from dns response)
- trim_suffix(dns_cname,'.ghost.io') == 'projectdiscovery' # check for cname (extracted information from dns response)
- ssl_subject_cn == 'blog.projectdiscovery.io'
condition: and