• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / blurts-server / e344e5ac-a6e8-41d2-93ce-59bc4110b9a3

pending completion
e344e5ac-a6e8-41d2-93ce-59bc4110b9a3

push

circleci

Vincent
Don't exposure exposure routes in prod

282 of 1758 branches covered (16.04%)

Branch coverage included in aggregate %.

4 of 4 new or added lines in 2 files covered. (100.0%)

959 of 4662 relevant lines covered (20.57%)

3.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/controllers/exposures.js
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4

5
import { mainLayout } from '../views/mainLayout.js'
6
import { generateToken } from '../utils/csrf.js'
7
import { exposuresSetup } from '../views/partials/exposuresSetup.js'
8
import { exposuresList } from '../views/partials/exposuresList.js'
9
import { listScanResults } from '../external/onerep.js'
10

11
/**
12
 * @type {import('express').RequestHandler}
13
 */
14
async function exposuresPage (req, res, next) {
15
  if (!req.user) {
×
16
    next()
×
17
    return
×
18
  }
19
  const user = req.user
×
20
  const showDashboard = hasSetUpExposureScanning(user)
×
21

22
  if (!showDashboard) {
×
23
    /**
24
     * @type {MainViewPartialData<import('../views/partials/exposuresSetup').PartialParameters>}
25
     */
26
    const data = {
×
27
      partial: exposuresSetup,
28
      csrfToken: generateToken(res, req),
29
      nonce: res.locals.nonce,
30
      fxaProfile: user.fxa_profile_json
31
    }
32
    res.send(mainLayout(data))
×
33
    return
×
34
  }
35

36
  const scanResults = await listScanResults(user.onerep_profile_id)
×
37
  /**
38
   * @type {MainViewPartialData<import('../views/partials/exposuresList').PartialParameters>}
39
   */
40
  const data = {
×
41
    partial: exposuresList,
42
    csrfToken: generateToken(res, req),
43
    nonce: res.locals.nonce,
44
    fxaProfile: user.fxa_profile_json,
45
    scanResults
46
  }
47

48
  res.send(mainLayout(data))
×
49
}
50

51
/**
52
 * @param {NonNullable<import('express').Request['user']>} user
53
 * @returns {user is import('express').Request['user'] & { onerep_profile_id: number }} Whether the user has set up exposure scanning already
54
 */
55
function hasSetUpExposureScanning (user) {
56
  return typeof user.onerep_profile_id === 'number'
×
57
}
58

59
export { exposuresPage }
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc