Skip to content

Commit

Permalink
{dev} Added automatic createdAt and updatedAt fields
Browse files Browse the repository at this point in the history
  • Loading branch information
adiffpirate committed Oct 5, 2023
1 parent cfaa29c commit f7697e1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion dev/_utils/get_vulns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fi
script_path=$(dirname "$0")

$script_path/query_dgraph.sh -t dql -q "{
results(func: gt(Vuln.updatedOn, \"$(date -Iseconds -d "-$past_time")\")) {
results(func: gt(Vuln.createdAt, \"$(date -Iseconds -d "-$past_time")\")) {
Vuln.name,
Vuln.evidence { Evidence.target }
}
Expand Down
8 changes: 3 additions & 5 deletions dev/_utils/save_dnsrecords.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ if [ -z "$records_csv_file" ] || [[ "$(head -n1 $records_csv_file)" != "domain|t
fi

script_path=$(dirname "$0")
now=$(date -Iseconds)

# Parse CSV
records_json_file=/tmp/records_file_$now.json
records_json_file=$(mktemp)
echo '[]' > $records_json_file
tail -n '+2' $records_csv_file | while read line; do
# Get vars
Expand All @@ -37,14 +36,13 @@ tail -n '+2' $records_csv_file | while read line; do
\"name\": \"$record_type: $domain\",
\"domain\": { \"name\": \"$domain\" },
\"type\": \"$record_type\",
\"values\": $values,
\"updatedOn\": \"$now\"
\"values\": $values
}
]" $records_json_file)"
echo -E "$list" > $records_json_file
done

query_file=/tmp/query_$(date -Iseconds).graphql
query_file=$(mktemp)
echo "
mutation {
addDnsRecord(input: $(cat $records_json_file), upsert: true){
Expand Down
15 changes: 13 additions & 2 deletions dev/dgraph-init/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ curl --silent $DGRAPH_ALPHA_HOST:$DGRAPH_ALPHA_HTTP_PORT/admin/schema --data '
id: ID!
name: String! @id @search(by: [hash, regexp])
domains: [Domain]
createdAt: DateTime @default(add: { value: "$now" })
updatedAt: DateTime @default(update: { value: "$now" })
}
type Domain {
Expand All @@ -26,6 +29,9 @@ curl --silent $DGRAPH_ALPHA_HOST:$DGRAPH_ALPHA_HTTP_PORT/admin/schema --data '
foundBy: [Tool] @hasInverse(field: subdomains)
dnsRecords: [DnsRecord] @hasInverse(field: domain)
vulns: [Vuln] @hasInverse(field: domain)
createdAt: DateTime @default(add: { value: "$now" })
updatedAt: DateTime @default(update: { value: "$now" })
}
type Tool {
Expand All @@ -42,21 +48,26 @@ curl --silent $DGRAPH_ALPHA_HOST:$DGRAPH_ALPHA_HTTP_PORT/admin/schema --data '
domain: Domain @hasInverse(field: dnsRecords)
type: String! @search(by: [hash])
values: [String!]! @search(by: [hash, regexp])
updatedOn: DateTime @search(by: [hour])
createdAt: DateTime @default(add: { value: "$now" })
updatedAt: DateTime @default(update: { value: "$now" })
}
type Vuln {
id: ID!
name: String! @id @search(by: [hash, regexp])
domain: Domain @hasInverse(field: vulns)
title: String! @search(by: [hash, regexp])
class: VulnClass @hasInverse(field: vulns)
description: String @search(by: [hash, regexp])
severity: String @search(by: [hash])
references: [String] @search(by: [hash, regexp])
evidence: Evidence
foundBy: [Tool] @hasInverse(field: vulns)
updatedOn: DateTime @search(by: [hour])
createdAt: DateTime @default(add: { value: "$now" })
updatedAt: DateTime @default(update: { value: "$now" })
}
type VulnClass {
Expand Down
3 changes: 1 addition & 2 deletions dev/subtko/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ parse_output(){
"severity": .info.severity,
"references": .info.reference,
"evidence": { "target": ."extracted-results"[0], "request": .request, "response": .response },
"foundBy": [ { "name": "nuclei", "type": "exploit" } ],
"updatedOn": .timestamp
"foundBy": [ { "name": "nuclei", "type": "exploit" } ]
}'
done
}
Expand Down

0 comments on commit f7697e1

Please sign in to comment.