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

juice-shop / juice-shop-ctf / 17167236709

22 Aug 2025 10:23PM UTC coverage: 90.832% (-8.0%) from 98.804%
17167236709

push

github

bkimminich
Fix Coveralls publishing to a used Node version

254 of 332 branches covered (76.51%)

961 of 1058 relevant lines covered (90.83%)

6.44 hits per line

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

92.5
/lib/fetchSecretKey.ts
1
/*
5!
2
 * Copyright (c) 2016-2025 Bjoern Kimminich & the OWASP Juice Shop contributors.
1✔
3
 * SPDX-License-Identifier: MIT
1✔
4
 */
1✔
5

1✔
6
import * as https from 'node:https'
1✔
7
import isUrl from './url'
1✔
8

1✔
9
async function fetchSecretKey (
5✔
10
  origin: string | undefined | null,
5✔
11
  ignoreSslWarnings: boolean,
5✔
12
  { fetch = globalThis.fetch } = { fetch: globalThis.fetch }
5✔
13
): Promise<string | null | undefined> {
5✔
14
  const agent = ignoreSslWarnings
5!
15
    ? new https.Agent({ rejectUnauthorized: false })
×
16
    : undefined
5✔
17

5✔
18
  if (origin !== null && origin !== undefined && isUrl(origin)) {
5✔
19
    try {
2✔
20
      const options = { agent }
2✔
21
      const response = await fetch(origin, options as RequestInit | undefined)
2✔
22

2✔
23
      if (!response.ok) {
2!
24
        throw new Error(`Failed to fetch: ${response.status}`)
×
25
      }
×
26

2✔
27
      const body = await response.text()
2✔
28
      return body
1✔
29
    } catch (err) {
1✔
30
      throw new Error(
1✔
31
        'Failed to fetch secret key from URL! ' +
1✔
32
          (err instanceof Error ? err.message : String(err))
1!
33
      )
1✔
34
    }
1✔
35
  } else {
5✔
36
    return origin
3✔
37
  }
3✔
38
}
5✔
39

1✔
40
export default fetchSecretKey
1✔
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