Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support Web Connectivity blocking "tls" #906

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions components/aggregation/mat/labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import PropTypes from 'prop-types'
import { Box } from 'ooni-components'

import { testNames } from '../../test-info'
import { getCategoryCodesMap } from '../../utils/categoryCodes'
import { getLocalisedRegionName } from 'utils/i18nCountries'

const InputRowLabel = ({ input }) => {
Expand All @@ -21,14 +20,13 @@ InputRowLabel.propTypes = {
input: PropTypes.string,
}

const categoryCodesMap = getCategoryCodesMap()

const blockingTypeLabels = {
'': '<empty>',
'dns': 'DNS Tampering',
'http-diff': 'HTTP Diff',
'http-failure': 'HTTP Failure',
'tcp_ip': 'TCP/IP Blocking'
'tcp_ip': 'TCP/IP Blocking',
'tls': 'TLS Blocking'
}

export const getRowLabel = (key, yAxis, locale = 'en') => {
Expand All @@ -47,10 +45,10 @@ export const getRowLabel = (key, yAxis, locale = 'en') => {
case 'probe_asn':
return `AS${key}`
case 'test_name':
return Object.keys(testNames).includes(key) ?
messages[testNames[key].id] :
return Object.keys(testNames).includes(key) ?
messages[testNames[key].id] :
key
default:
return key
}
}
}
46 changes: 25 additions & 21 deletions components/measurement/nettests/WebConnectivity.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ const messages = defineMessages({
id: 'Measurement.SummaryText.Websites.Anomaly.BlockingReason.TCP',
defaultMessage: ''
},
'blockingReason.tls': {
id: 'Measurement.SummaryText.Websites.Anomaly.BlockingReason.TLS',
defaultMessage: ''
},
'connection.Success': {
id: 'Measurement.Details.Websites.TCP.ConnectionTo.Success',
defaultMessage: ''
Expand Down Expand Up @@ -64,7 +68,7 @@ const HttpResponseBodyContainer = styled(WrappedPre)`
overflow: auto;
`

const HttpResponseBody = ({request}) => {
const HttpResponseBody = ({ request }) => {
let body

if (!request || !request.response || !request.response.body) {
Expand All @@ -86,7 +90,7 @@ HttpResponseBody.propTypes = {
request: PropTypes.object.isRequired
}

const RequestResponseContainer = ({request}) => {
const RequestResponseContainer = ({ request }) => {
return (
// FIXME: This sometime ends up creating empty sections with just a title
// when request data contains states like 'generic_timeout_error'
Expand All @@ -96,7 +100,7 @@ const RequestResponseContainer = ({request}) => {
<FormattedMessage id='General.NoData' />
</Box>
) : (
// !request.failure &&
// !request.failure &&
<Box>
<Flex flexWrap='wrap'>
{/* Request URL */}
Expand Down Expand Up @@ -143,7 +147,7 @@ RequestResponseContainer.propTypes = {
request: PropTypes.object.isRequired
}

const FailureString = ({failure}) => {
const FailureString = ({ failure }) => {
if (typeof failure === 'undefined') {
return (<FormattedMessage id='General.NoData' />)
}
Expand All @@ -167,25 +171,25 @@ FailureString.propTypes = {
}

const DnsNarrowAnswerCell = (props) => (
<Box width={1/12}>{props.children}</Box>
<Box width={1 / 12}>{props.children}</Box>
)

const DnsAnswerCell = (props) => (
<Box width={1/4}>{props.children}</Box>
<Box width={1 / 4}>{props.children}</Box>
)

DnsAnswerCell.propTypes = {
children: PropTypes.any
}

const dnsAnswerIpInfo = (dnsAnswer) => {
const asn = dnsAnswer.asn ? `AS${dnsAnswer.asn}` : 'Unknown AS'
const asOrgName = dnsAnswer.as_org_name ? `(${dnsAnswer.as_org_name})` : ''
const asn = dnsAnswer.asn ? `AS${dnsAnswer.asn}` : 'Unknown AS'
const asOrgName = dnsAnswer.as_org_name ? `(${dnsAnswer.as_org_name})` : ''

return `${asn} ${asOrgName}`.trim()
return `${asn} ${asOrgName}`.trim()
}

const DnsAnswerRow = ({ name = 'Name', netClass = 'Class', ttl = 'TTL', type = 'Type', data = 'DATA', answer_ip_info = 'Answer IP Info', header = false}) => (
const DnsAnswerRow = ({ name = 'Name', netClass = 'Class', ttl = 'TTL', type = 'Type', data = 'DATA', answer_ip_info = 'Answer IP Info', header = false }) => (
<Text fontWeight={header ? 'bold' : undefined}>
<Flex flexWrap='wrap' mb={2}>
<DnsAnswerCell>{name}</DnsAnswerCell>
Expand All @@ -208,7 +212,7 @@ DnsAnswerRow.propTypes = {
header: PropTypes.bool
}

const QueryContainer = ({query}) => {
const QueryContainer = ({ query }) => {
const {
query_type,
answers,
Expand Down Expand Up @@ -346,7 +350,7 @@ const WebConnectivityDetails = ({

const intl = useIntl()
const date = new Intl.DateTimeFormat(intl.locale, { dateStyle: 'long', timeStyle: 'long', timeZone: 'UTC' }).format(new Date(measurement_start_time))

const p = url.parse(input)
const hostname = p.host

Expand All @@ -367,7 +371,7 @@ const WebConnectivityDetails = ({
country
}}
/>
} else if(isConfirmed) {
} else if (isConfirmed) {
status = 'confirmed'
summaryText = <FormattedMessage
id='Measurement.SummaryText.Websites.ConfirmedBlocked'
Expand Down Expand Up @@ -500,13 +504,13 @@ const WebConnectivityDetails = ({
<>
{render({
status: status,
statusInfo: <StatusInfo
statusInfo: <StatusInfo
title={
<StyledStatusInfoLink href={`/domain/${hostname}`}>
{input}
</StyledStatusInfoLink>
}
message={reason}
message={reason}
/>,
summaryText: summaryText,
headMetadata: headMetadata,
Expand All @@ -518,22 +522,22 @@ const WebConnectivityDetails = ({
title={<FormattedMessage id='Measurement.Details.Websites.Failures.Heading' />}
content={
<Flex mb={2} flexWrap='wrap'>
<Box width={1/3}>
<Box width={1 / 3}>
<FormattedMessage id='Measurement.Details.Websites.Failures.Label.HTTP' />
</Box>
<Box width={2/3}>
<Box width={2 / 3}>
<FailureString failure={http_experiment_failure} />
</Box>
<Box width={1/3}>
<Box width={1 / 3}>
<FormattedMessage id='Measurement.Details.Websites.Failures.Label.DNS' />
</Box>
<Box width={2/3}>
<Box width={2 / 3}>
<FailureString failure={dns_experiment_failure} />
</Box>
<Box width={1/3}>
<Box width={1 / 3}>
<FormattedMessage id='Measurement.Details.Websites.Failures.Label.Control' />
</Box>
<Box width={2/3}>
<Box width={2 / 3}>
<FailureString failure={control_failure} />
</Box>
</Flex>
Expand Down
1 change: 1 addition & 0 deletions public/static/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"Measurement.SummaryText.Websites.Anomaly": "On {date}, {WebsiteURL} presented signs of {reason} on {network} in {country}.\n\nThis might mean that {WebsiteURL} was blocked, but <link-to-docs>false positives</link-to-docs> can occur.\n\nPlease explore the network measurement data below.",
"Measurement.SummaryText.Websites.Anomaly.BlockingReason.DNS": "DNS tampering",
"Measurement.SummaryText.Websites.Anomaly.BlockingReason.TCP": "TCP/IP blocking",
"Measurement.SummaryText.Websites.Anomaly.BlockingReason.TLS": "TLS blocking",
"Measurement.SummaryText.Websites.Anomaly.BlockingReason.HTTP-failure": "HTTP blocking (HTTP requests failed)",
"Measurement.SummaryText.Websites.Anomaly.BlockingReason.HTTP-diff": "HTTP blocking (a blockpage might be served)",
"Measurement.SummaryText.Websites.ConfirmedBlocked": "On {date}, {WebsiteURL} was blocked on {network} in {country}.\n\nThis is confirmed because a block page was served, as illustrated through the network measurement data below.",
Expand Down
Loading