Skip to content

Commit

Permalink
add timestamp to scan results (#4614)
Browse files Browse the repository at this point in the history
  • Loading branch information
lcampbell2 committed Jun 29, 2023
1 parent 48f04e5 commit 9bbeb47
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
10 changes: 9 additions & 1 deletion frontend/src/guidance/EmailGuidance.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,18 @@ export function EmailGuidance({ dnsResults, dmarcPhase, status }) {
break
}

const formatTimestamp = (ts) => {
const dateTime = ts.split('T')
return dateTime[0] + ', ' + dateTime[1].substring(0, 5)
}

const dmarcStepList = !dmarcSteps
? undefined
: dmarcSteps.map((step, idx) => {
return <ListItem key={idx}>{step}</ListItem>
})

const { dkim, dmarc, spf } = dnsResults
const { dkim, dmarc, spf, timestamp } = dnsResults
const emailKeys = ['spf', 'dkim', 'dmarc']
let emailPassCount = 0
let emailInfoCount = 0
Expand Down Expand Up @@ -145,6 +150,9 @@ export function EmailGuidance({ dnsResults, dmarcPhase, status }) {
)
return (
<Accordion allowMultiple defaultIndex={[0, 1, 2, 3]}>
<Text fontsize="lg">
<b>Last Scanned:</b> {formatTimestamp(timestamp)}
</Text>
{emailSummary}
<Box mb={4} ml="4">
<Text fontWeight="bold" fontSize="2xl">
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/guidance/GuidancePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function GuidancePage() {
</Box>
)
} else {
const { results: webResults } = webScan?.edges[0]?.node
const { results: webResults, timestamp } = webScan?.edges[0]?.node
const { node: dnsResults } = dnsScan?.edges[0]

const noScanData = (
Expand All @@ -121,7 +121,11 @@ function GuidancePage() {
</TabList>
<TabPanels>
<TabPanel>
{webResults.length === 0 ? noScanData : <WebGuidance webResults={webResults} status={status} />}
{webResults.length === 0 ? (
noScanData
) : (
<WebGuidance webResults={webResults} status={status} timestamp={timestamp} />
)}
</TabPanel>
<TabPanel>
{dnsScan.edges.length === 0 ? (
Expand Down
12 changes: 11 additions & 1 deletion frontend/src/guidance/WebGuidance.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import { Trans } from '@lingui/macro'
import { WebTLSResults } from './WebTLSResults'
import { WebConnectionResults } from './WebConnectionResults'
import { GuidanceSummaryCategories } from './GuidanceSummaryCategories'
import { string } from 'prop-types'

export function WebGuidance({ webResults }) {
export function WebGuidance({ webResults, timestamp }) {
const [selectedEndpoint, setSelectedEndpoint] = useState(webResults[0].ipAddress)

let totalWebPass = 0
Expand Down Expand Up @@ -117,9 +118,17 @@ export function WebGuidance({ webResults }) {
return ipAddress === selectedEndpoint
}).results

const formatTimestamp = (ts) => {
const dateTime = ts.split('T')
return dateTime[0] + ', ' + dateTime[1].substring(0, 5)
}

return (
<>
<Accordion allowMultiple defaultIndex={[0, 1, 2]}>
<Text fontsize="lg">
<b>Last Scanned:</b> {formatTimestamp(timestamp)}
</Text>
{!isWebHosting && (
<Flex
fontSize="lg"
Expand Down Expand Up @@ -150,4 +159,5 @@ export function WebGuidance({ webResults }) {

WebGuidance.propTypes = {
webResults: array,
timestamp: string,
}

0 comments on commit 9bbeb47

Please sign in to comment.