Skip to content

Commit

Permalink
count lookups (#53)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Sharpe <[email protected]>
  • Loading branch information
asharpe and Andrew Sharpe authored Jun 26, 2024
1 parent fd96000 commit 9b48bb7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/SpfInspector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type Search = {
type Status = {
found: boolean;
match: boolean;
lookups: number;
} & Search;

const isRawIp = (domain: string): boolean =>
Expand All @@ -52,6 +53,7 @@ const SpfInspector = (
includes: [],
domains: [],
match: false,
lookups: 0,
};

const getDnsRecord = (domain: string): Promise<Record[]> => {
Expand Down Expand Up @@ -100,6 +102,7 @@ const SpfInspector = (
.filter(propEq(SpfType.include, "type"))
.map(prop("value"))
.forEach((include) => {
status.lookups += 1;
if (contains(include, status.includes)) return;
// * Mutate the state
status.includes.push(include);
Expand All @@ -110,6 +113,7 @@ const SpfInspector = (
.filter(propEq(SpfType.a, "type"))
.map(prop("value"))
.forEach((domain) => {
status.lookups += 1;
if (contains(domain, status.domains)) return;
// * Mutate the state
status.domains.push(domain);
Expand Down Expand Up @@ -188,6 +192,7 @@ const SpfInspector = (
domains: helperRemoveEmpty(status.domains),
},
isMatch: status.match,
lookups: status.lookups,
reason: "",
});
})
Expand All @@ -200,6 +205,7 @@ const SpfInspector = (
domains: [],
},
isMatch: false,
lookups: 0,
reason: InspecterError.NOTFOUND,
});
});
Expand Down

0 comments on commit 9b48bb7

Please sign in to comment.