Skip to content

Commit

Permalink
fix trailing dot (#4295)
Browse files Browse the repository at this point in the history
* fix trailing dot

* remove trailing dot from `domain`

* remove trailing dots from answer

* remove dots

* fix integration test
  • Loading branch information
dogancanbakir authored Nov 1, 2023
1 parent 8371223 commit c79d2f0
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion integration_tests/protocols/multi/dynamic-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dns:
- type: dsl
name: blogid
dsl:
- trim_suffix(cname,'.ghost.io.')
- trim_suffix(cname,'.ghost.io')
internal: true

http:
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/protocols/multi/evaluate-variables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion pkg/protocols/dns/operators.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pkg/protocols/dns/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion pkg/tmplexec/multiproto/testcases/multiprotodynamic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dns:
- type: dsl
name: blogid
dsl:
- trim_suffix(cname,'.ghost.io.')
- trim_suffix(cname,'.ghost.io')
internal: true


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c79d2f0

Please sign in to comment.