Skip to content

Commit

Permalink
fixed the JSON portion of the query
Browse files Browse the repository at this point in the history
  • Loading branch information
caffix committed Nov 29, 2024
1 parent d6c1c79 commit a937f1f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions initdb-assetdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$AMASS_DB" <<-EOSQ
INNER JOIN entities AS ips ON r2.to_entity_id = ips.entity_id)
WHERE fqdns.etype = 'FQDN' AND srvs.etype = 'FQDN' AND ips.etype = 'IPAddress'
AND r1.etype IN ('PrefDNSRelation', 'SRVDNSRelation') AND r1.content->>'label' = 'dns_record'
AND r1.content->>'header.rr_type' IN ('33', '2', '15')
AND r1.content->'header'->'rr_type' IN ('33', '2', '15')
AND r2.etype = 'BasicDNSRelation' AND r2.content->>'label' = 'dns_record'
AND r2.content->>'header.rr_type' IN ('1', '28')
AND r2.content->'header'->'rr_type' IN ('1', '28')
AND r1.updated_at >= _from AND r1.updated_at <= _to AND r2.updated_at >= _from
AND r2.updated_at <= _to AND fqdns.content->>'name' = ANY(_names)
) LOOP fqdn = _var_r.name;
Expand All @@ -62,7 +62,7 @@ psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$AMASS_DB" <<-EOSQ
INNER JOIN entities AS ips ON edges.to_entity_id = ips.entity_id)
WHERE fqdns.etype = 'FQDN' AND ips.etype = 'IPAddress'
AND edges.etype = 'BasicDNSRelation' AND edges.content->>'label' = 'dns_record'
AND edges.content->>'header.rr_type' IN ('1', '28') AND edges.updated_at >= _from
AND edges.content->'header'->'rr_type' IN ('1', '28') AND edges.updated_at >= _from
AND edges.updated_at <= _to AND fqdns.content->>'name' = ANY(_names)
) LOOP fqdn = _var_r.name;
ip_addr = _var_r.addr;
Expand All @@ -81,15 +81,15 @@ psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$AMASS_DB" <<-EOSQ
WHERE fqdns.etype = 'FQDN' AND cnames.etype = 'FQDN'
AND edges.updated_at >= _from AND edges.updated_at <= _to
AND edges.etype = 'BasicDNSRelation' AND edges.content->>'label' = 'dns_record'
AND edges.content->>'header.rr_type' = '5'
AND edges.content->'header'->'rr_type' = '5'
AND fqdns.content->>'name' = traverse_cname._fqdn)
SELECT fqdns.content->>'name' AS "name", ips.content->>'address' AS "addr"
FROM ((entities AS fqdns INNER JOIN edges ON fqdns.entity_id = edges.from_entity_id)
INNER JOIN entities AS ips ON edges.to_entity_id = ips.entity_id)
WHERE fqdns.etype = 'FQDN' AND ips.etype = 'IPAddress'
AND edges.updated_at >= _from AND edges.updated_at <= _to
AND edges.etype = 'BasicDNSRelation' AND edges.content->>'label' = 'dns_record'
AND edges.content->>'header.rr_type' IN ('1', '28')
AND edges.content->'header'->'rr_type' IN ('1', '28')
AND fqdns.content->>'name' IN (SELECT _fqdn FROM traverse_cname)
) LOOP fqdn = _name;
ip_addr = _var_r.addr;
Expand Down

0 comments on commit a937f1f

Please sign in to comment.