Firefox Monitor arms you with tools to keep your personal information safe. Find out what hackers already know about you and learn how to stay a step ahead of them.
Перейти к файлу
Peter deHaan 1fdda7c2b4
Fixing l10n linter errors/warnings (#3242)
2023-07-22 09:34:22 -07:00
.circleci Merge Next.js into `main` (#3116) 2023-06-12 13:35:35 -07:00
.github MNTOR-1403 - land mock data, type definition, and faker code for OneRep types (#3166) 2023-07-10 23:50:41 -07:00
.husky Merge Next.js into `main` (#3116) 2023-06-12 13:35:35 -07:00
.storybook Unblock Storybook-in-tests with l10n 2023-07-11 12:58:19 +02:00
.vscode Merge Next.js into `main` (#3116) 2023-06-12 13:35:35 -07:00
docs Update CODEOWNERS (#3239) 2023-07-20 23:50:42 -07:00
locales Add "clothing-sizes" to data-classes.ftl (#3241) 2023-07-21 12:08:33 -07:00
locales-pending Fixing l10n linter errors/warnings (#3242) 2023-07-22 09:34:22 -07:00
patches Merge Next.js into `main` (#3116) 2023-06-12 13:35:35 -07:00
public MNTOR-1403 - data removal action and scan (#3157) 2023-07-13 15:02:07 -07:00
scripts fix import 2023-07-14 15:35:44 -07:00
src Fixup exposure cards UI (#3236) 2023-07-21 14:37:28 -07:00
.dockerignore Removes version.json from the .dockerignore file. 2018-06-08 16:21:54 -04:00
.env-dist chore: Add .env variable for total broker count 2023-07-18 13:22:52 +02:00
.eslintignore fix ESLint errors and update config 2023-04-24 21:24:35 -07:00
.eslintrc.json Enable type-checked linting rules 2023-07-10 10:36:45 +02:00
.git-blame-ignore-revs Add commit 9cf79b6 to .git-blame-ignore-revs 2023-06-20 18:42:41 +02:00
.gitignore chore: Use os tmpdir for downloaded data 2023-07-05 11:50:53 +02:00
.lintstagedrc.js Also run Prettier and ESLint on .mjs and .cjs 2023-07-04 12:19:45 +02:00
.npmrc add npmrc to strictly enforce node engine before install 2020-11-05 15:53:26 -06:00
.prettierignore fix: Apply prettier for scr/app 2023-06-20 18:07:48 +02:00
.prettierrc.json Merge Next.js into `main` (#3116) 2023-06-12 13:35:35 -07:00
.stylelintignore Merge Next.js into `main` (#3116) 2023-06-12 13:35:35 -07:00
.stylelintrc Merge Next.js into `main` (#3116) 2023-06-12 13:35:35 -07:00
CODE_OF_CONDUCT.md Add Mozilla Code of Conduct file 2019-03-30 00:10:15 -07:00
Dockerfile add build step in dockerfile (#3123) 2023-06-13 18:40:19 -07:00
LICENSE Add LICENSE file and update package.json license 2018-06-07 14:49:16 -07:00
Procfile Migrate the database on deploy 2022-08-23 10:28:18 -05:00
README.md chore: Add note regarding create-location-data to README 2023-07-11 10:25:28 +02:00
esbuild.js move esbuild and package.json to root 2023-04-20 15:25:51 -07:00
jest.config.cjs Add first screen of the onboarding flow 2023-07-07 18:15:09 +02:00
jest.setup.ts Add first screen of the onboarding flow 2023-07-07 18:15:09 +02:00
l10n.toml Update l10n linter to moz-l10n-lint 2019-05-09 15:20:06 -07:00
netlify.toml Merge Next.js into `main` (#3116) 2023-06-12 13:35:35 -07:00
next-env.d.ts Merge Next.js into `main` (#3116) 2023-06-12 13:35:35 -07:00
next.config.js fix: FxA profile image for prod 2023-07-12 19:14:19 +02:00
package-lock.json try init sentry and capture 2023-07-13 12:57:31 -07:00
package.json try init sentry and capture 2023-07-13 12:57:31 -07:00
playwright.config.js chore: Increase playwright timeout value 2023-07-05 13:29:00 +02:00
sentry.client.config.ts config: disable Sentry debug logging, and only enable full traces in dev envs (#3138) 2023-06-22 18:43:22 -07:00
sentry.edge.config.ts MNTOR-949/check subscriptions on dashboard (#3147) 2023-06-22 20:30:16 -07:00
sentry.server.config.ts config: disable Sentry debug logging, and only enable full traces in dev envs (#3138) 2023-06-22 18:43:22 -07:00
tsconfig.json Add first screen of the onboarding flow 2023-07-07 18:15:09 +02:00

README.md

Firefox Monitor Server

Coverage Status

Summary

Firefox Monitor notifies users when their credentials have been compromised in a data breach.

This code is for the monitor.firefox.com service & website.

Breach data is powered by haveibeenpwned.com.

See the Have I Been Pwned about page for the "what" and "why" of data breach alerts.

Architecture

Image of Monitor architecture

Development

Requirements

  • Volta (installs the correct version of Node and npm)
  • Postgres | Note: On a Mac, we recommend downloading the Postgres.app instead.

Code style

Linting and formatting is enforced via ESLint and Stylelint for JS and CSS. Both are installed as dev-dependencies and can be run with npm run lint. A push to origin will also trigger linting.

ESLint rules are based on eslint-config-standard. To fix all auto-fixable problems, run npx eslint . --fix

Stylelint rules are based on stylelint-config-standard. To fix all auto-fixable problems, run npx stylelint public/css/ --fix

GIT

We track commits that are largely style/formatting via .git-blame-ignore-revs. This allows Git Blame to ignore the format commit author and show the original code author. In order to enable this in GitLens, add the following to VS Code settings.json:

"gitlens.advanced.blame.customArguments": [
   "--ignore-revs-file",
   ".git-blame-ignore-revs"
],

Prerequisites

  1. Create location data: Running the script manually is only needed for local development. The location data is being used in the onboarding exposures scan for autocompleting the “City and state” input.

    npm run create-location-data
    

Install

  1. Clone and change to the directory:

    git clone https://github.com/mozilla/blurts-server.git
    cd blurts-server
    
  2. Install dependencies:

    npm install
    
  3. Copy the .env-dist file to .env:

    cp .env-dist .env
    
  4. Install fluent linter (requires Python)

    pip install -r .github/requirements.txt
    
    OR
    
    pip3 install -r .github/requirements.txt
    

Run

  1. To run the server similar to production using a build phase, which includes minified and bundled assets:

    npm start
    

    OR

    Run in "dev mode", which loads unbundled client modules and uncompressed assets directly, and uses Nodemon to auto-restart the Express process when any server files change:

    npm run dev
    
  2. You may receive the error Required environment variable was not set. If this is the case, get the required env var(s) from another team member or ask in #fx-monitor-engineering. Otherwise, if the server started successfully, navigate to localhost:6060

Cloud Functions

User breach notifications from HIBP are handled by a GCP Cloud Function. This can be emulated locally:

npm run functions

This function serves the /api/v1/hibp/notify route, which is responsible for:

  1. receiving HTTP POST payloads with a bearer token from HIBP
  2. emailing any affected users

This can be tested using curl:

curl \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer unsafe-default-token-for-dev' \
  -X POST \
  -d '{"breachName": "Gravatar", "hashPrefix": "...", "hashSuffixes": ["..."]}' \
  localhost:8080/api/v1/hibp/notify

Database

To create the database tables ...

  1. Create the blurts database:

    createdb blurts
    createdb test-blurts # for tests
    
  2. Update the DATABASE_URL value in your .env file with your local db credentials:

    DATABASE_URL="postgres://<username>:<password>@localhost:<port>/blurts"
    
  3. Run the migrations:

    npm run db:migrate
    

Emails

Monitor generates multiple emails that get sent to subscribers. To preview or test-send these emails see documentation here.

Firefox Accounts

Subscribe with a Firefox Account is controlled via the FXA_ENABLED environment variable. (See .env-dist)

The repo comes with a development FxA oauth app pre-configured in .env, which should work fine running the app on http://localhost:6060. You'll need to get the OAUTH_CLIENT_SECRET value from a team member or someone in #fxmonitor-engineering.

Testing

The unit test suite can be run via npm test.

At the beginning of a test suite run, the test-blurts database will be populated with test tables and seed data found in src/db/seeds/

At the end of a test suite run in CircleCI, coverage info will be sent to Coveralls to assess coverage changes and provide a neat badge. To upload coverage locally, you need a root .coveralls.yml which contains a token – get this from another member of the Monitor team.

End-to-End tests use Playwright and can be run via npm run e2e.

Test Firefox Integration

TODO: the following functionality is disabled but the instructions are left here for posterity.

Firefox's internal about:protections page ("Protections Dashboard") fetches and displays breach stats for Firefox users who are signed into their FXA.

To test this part of Monitor:

  1. Set a Firefox profile to use the staging Firefox Accounts server.
  2. In the same profile, go to about:config and replace all https://monitor.firefox.com values with http://localhost:6060
  3. Restart Firefox with that profile.
  4. Go to about:protections
  5. Everything should be using your localhost instance of Monitor.

Localization

This repository has a dedicated branch for localization called... localization. To add localized text, add or update the relevant .ftl file under locales/en. Be sure to reference the localization documentation for best practices.

To trigger translations, open a pull request against localization. Please be mindful that Mozilla localizers are volunteers, and translations come from different locales at different times – usually after a week or more. It's best to initiate a PR when your strings are more-or-less final. Your PR should be automatically tagged with a reviewer from the Mozilla L10n team to approve your request.

After your updates are merged into localization, you will start to see commits from Pontoon, Mozilla's localization platform. You can also check translation status via the Pontoon site.

When enough translations have been commited, you should merge localization into main, or back into your feature branch if it's not yet merged to main. Note it's unlikely to have 100% of locales translated. You might discuss with stakeholders which locales are priority.

Important: Do not use "Squash" or "Rebase" to merge localization into main or vice versa. Doing so creates new commit hashes and the branches will appear out of sync.

TODO: explore means to auto-sync localization with main

Deploy on Heroku

We use Heroku apps for dev review only – official stage and production apps are built by the Dockerfile and CircleCI config, with deploy overseen by the Site Reliability Engineering team.

A merge to main auto-deploys that branch to Heroku. We also employ Heroku's "Review Apps" to check Pull Requests. These are currently set to auto-deploy: you can find the app link in your GitHub Pull Request. Review apps auto-destroy after 2 days of inactivity.

If you encounter issues with Heroku deploys, be sure to check your environment variables, including those required in app-constants.js. Review apps also share a database and you should not assume good data integrity if testing db-related features.

TODO: add full deploy process similar to Relay

TODO: consider whether we can re-enable Heroku Review Apps

Preserve sessions in local development

Sessions by default are stored in-memory, which means that when the server restarts (e.g. because you made a code change), you will have to log in again.

To avoid this hassle, you can install and run Redis, which by default runs on redis://localhost:6379. Use that value for REDIS_URL in your .env file to preserve your sessions across server restarts.