import { useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; import { useGleanClick } from "../telemetry/glean-context"; import { OBSERVATORY } from "../telemetry/constants"; import Container from "../ui/atoms/container"; import { SidePlacement } from "../ui/organisms/placement"; import { OBSERVATORY_TITLE, OBSERVATORY_TITLE_FULL, } from "../../../libs/constants"; import { ObservatoryAnalyzeRequest } from "./types"; import { ObservatoryLayout } from "./layout"; import { Progress } from "./progress"; import { ERROR_MAP, FaqLink, FeedbackLink, useUpdateResult } from "./utils"; import "./landing.scss"; import { ReactComponent as LandingSVG } from "../../public/assets/observatory/landing-illustration.svg"; import { ReactComponent as LinesSVG } from "../../public/assets/observatory/lines.svg"; import { ReactComponent as AssessmentSVG } from "../../public/assets/observatory/assessment.svg"; import { ReactComponent as ScanningSVG } from "../../public/assets/observatory/scanning.svg"; import { ReactComponent as SecuritySVG } from "../../public/assets/observatory/security.svg"; import { ReactComponent as MdnSVG } from "../../public/assets/observatory/mdn.svg"; export default function ObservatoryLanding() { document.title = `HTTP Header Security Test - ${OBSERVATORY_TITLE_FULL}`; const [form, setForm] = useState({ host: "", }); const [cleanHostname, setCleanHostname] = useState(""); const { trigger, isMutating, data, error: updateError, } = useUpdateResult(cleanHostname); const [error, setError] = useState(); const navigate = useNavigate(); useEffect(() => { try { // tolerate url-style host values and pick out the hostname part const url = new URL(form.host); setCleanHostname(url.hostname.trim() || form.host); } catch { setCleanHostname(form.host); } }, [form.host]); useEffect(() => { if (!isMutating && data) { if (data.scan.error) { setError(new Error(data.scan.error)); } else { navigate(`./analyze?host=${encodeURIComponent(cleanHostname)}`); } } }, [isMutating, data, navigate, cleanHostname]); useEffect(() => { setError(updateError); }, [updateError]); const submit: React.FormEventHandler = async (e) => { e.preventDefault(); setError(undefined); if (form.host.trim().length === 0) { setError(new Error("Please enter a valid hostname")); } else { trigger(); } }; const gleanClick = useGleanClick(); useEffect(() => { if (error && !isMutating) { gleanClick( `${OBSERVATORY}: error -> ${ERROR_MAP[error.name] || error.name || error.message}` ); } }, [error, isMutating, gleanClick]); return (

{OBSERVATORY_TITLE}

Launched in 2016, the HTTP Observatory enhances web security by analyzing compliance with best security practices. It has provided insights to over 6.9 million websites through 47 million scans.

{isMutating ? ( ) : (
setForm({ ...form, host: e.target.value }) } />
)} {error && !isMutating && (
Error: {ERROR_MAP[error.name] || error.message}
)}

About the HTTP Observatory

Developed by Mozilla, the HTTP Observatory performs an in-depth assessment of a site’s HTTP headers and other key security configurations.

Its automated scanning process provides developers and website administrators with detailed, actionable feedback, focusing on identifying and addressing potential security vulnerabilities.

The tool is instrumental in helping developers and website administrators strengthen their sites against common security threats in a constantly advancing digital environment.

The HTTP Observatory provides effective security insights, guided by Mozilla's expertise and commitment to a safer and more secure internet and based on well-established trends and guidelines.

); }