Skip to content

Commit ab3dc68

Browse files
authored
Merge pull request #7 from browserstack/LTS-5442-selenium-sample-security
LTS-5442: harden selenium sample (Semgrep pin, jest lockfile, web-security flag, credential + CLI-verify guidance)
2 parents c0b892c + 3adcebd commit ab3dc68

21 files changed

Lines changed: 3727 additions & 46 deletions

File tree

‎.github/workflows/Semgrep.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727

2828
container:
2929
# A Docker image with Semgrep installed. Do not change this.
30-
image: returntocorp/semgrep:1.166.0
30+
image: returntocorp/semgrep:1.166.0@sha256:c180f0c93a17b420c0af5006214a29d3c747c5459c732b740191adf657dd0068
3131
# Skip any PR created by dependabot to avoid permission issues:
3232
if: (github.actor != 'dependabot[bot]')
3333

‎.gitignore‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@
33
**/browserstack-cli
44
**/.DS_Store
55
**/node_modules/
6-
**/package-lock.json
76
**/yarn.lock
87
**/pnpm-lock.yaml

‎README.md‎

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,38 @@
4040
[browserstack-cli-windows](https://load-api.browserstack.com/api/v1/binary?os=win&arch=x64)
4141

4242
- **Linux x86**
43-
[browserstack-cli-linux-x86](https://load-api.browserstack.com/api/v1/binary?os=linux&arch=arm64)
43+
[browserstack-cli-linux-x86](https://load-api.browserstack.com/api/v1/binary?os=linux&arch=x64)
4444

4545
- **Linux ARM**
46-
[browserstack-cli-linux-arm](https://load-api.browserstack.com/api/v1/binary?os=linux&arch=x64)
46+
[browserstack-cli-linux-arm](https://load-api.browserstack.com/api/v1/binary?os=linux&arch=arm64)
4747

48-
> Place the downloaded `browserstack-cli` binary in the root of your project.
48+
> The download is a zip. Extract it and place the `browserstack-cli` binary in the root of your project.
4949
50-
5. **Run tests using BrowserStack CLI**
50+
5. **Verify the BrowserStack CLI**
51+
52+
Before running the binary, check that it is signed by BrowserStack:
53+
54+
- **macOS**: the output must include `TeamIdentifier=YQ5FZQ855D` (Browserstack Inc).
55+
56+
```sh
57+
codesign --verify --strict ./browserstack-cli && codesign -dv ./browserstack-cli 2>&1 | grep TeamIdentifier
58+
```
59+
60+
- **Windows** (PowerShell): `Status` must be `Valid` and the signer must be BrowserStack.
61+
62+
```powershell
63+
Get-AuthenticodeSignature .\browserstack-cli.exe | Format-List Status, SignerCertificate
64+
```
65+
66+
If the check fails, do not run the binary.
67+
68+
6. **Run tests using BrowserStack CLI**
5169

5270
```sh
5371
./browserstack-cli load run
5472
```
5573

56-
6. **View Test Results**
74+
7. **View Test Results**
5775

5876
Visit the [BrowserStack Load-Testing Dashboard](https://load.browserstack.com/projects) to monitor and analyze your test runs.
5977

‎java/README.md‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,33 @@
3939
- **Linux ARM**
4040
[browserstack-cli-linux-arm](https://load-api.browserstack.com/api/v1/binary?os=linux&arch=arm64)
4141

42-
> Place the downloaded `browserstack-cli` binary in the root of your project.
42+
> The download is a zip. Extract it and place the `browserstack-cli` binary in the root of your project.
4343
44-
4. **Run tests using BrowserStack CLI**
44+
4. **Verify the BrowserStack CLI**
45+
46+
Before running the binary, check that it is signed by BrowserStack:
47+
48+
- **macOS**: the output must include `TeamIdentifier=YQ5FZQ855D` (Browserstack Inc).
49+
50+
```sh
51+
codesign --verify --strict ./browserstack-cli && codesign -dv ./browserstack-cli 2>&1 | grep TeamIdentifier
52+
```
53+
54+
- **Windows** (PowerShell): `Status` must be `Valid` and the signer must be BrowserStack.
55+
56+
```powershell
57+
Get-AuthenticodeSignature .\browserstack-cli.exe | Format-List Status, SignerCertificate
58+
```
59+
60+
If the check fails, do not run the binary.
61+
62+
5. **Run tests using BrowserStack CLI**
4563

4664
```sh
4765
./browserstack-cli load run
4866
```
4967

50-
5. **View Test Results**
68+
6. **View Test Results**
5169

5270
Visit the [BrowserStack Load-Testing Dashboard](https://load.browserstack.com/projects) to monitor and analyze your test runs.
5371

‎java/browserstack-load.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# =============================
22
# Set BrowserStack Credentials
33
# =============================
4-
# Add your BrowserStack userName and accessKey here or set BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY as env variables.
4+
# Set BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY as env variables. They override the placeholders below.
5+
# Do not paste your real access key into this file: it is easy to commit and push by mistake.
56
userName: BROWSERSTACK_USERNAME
67
accessKey: BROWSERSTACK_ACCESS_KEY
78

‎java/src/test/java/com/example/SimpleTest.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ private WebDriver createDriver() throws Exception {
6565
"--disable-renderer-backgrounding",
6666
"--disable-features=TranslateUI",
6767
"--disable-ipc-flooding-protection",
68-
"--disable-web-security",
6968
"--disable-features=VizDisplayCompositor",
7069
"--disable-logging",
7170
"--silent"

‎jest/README.md‎

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,38 @@
3434
[browserstack-cli-windows](https://load-api.browserstack.com/api/v1/binary?os=win&arch=x64)
3535

3636
- **Linux x86**
37-
[browserstack-cli-linux-x86](https://load-api.browserstack.com/api/v1/binary?os=linux&arch=arm64)
37+
[browserstack-cli-linux-x86](https://load-api.browserstack.com/api/v1/binary?os=linux&arch=x64)
3838

3939
- **Linux ARM**
40-
[browserstack-cli-linux-arm](https://load-api.browserstack.com/api/v1/binary?os=linux&arch=x64)
40+
[browserstack-cli-linux-arm](https://load-api.browserstack.com/api/v1/binary?os=linux&arch=arm64)
4141

42-
> Place the downloaded `browserstack-cli` binary in the root of your project.
42+
> The download is a zip. Extract it and place the `browserstack-cli` binary in the root of your project.
4343
44-
4. **Run tests using BrowserStack CLI**
44+
4. **Verify the BrowserStack CLI**
45+
46+
Before running the binary, check that it is signed by BrowserStack:
47+
48+
- **macOS**: the output must include `TeamIdentifier=YQ5FZQ855D` (Browserstack Inc).
49+
50+
```sh
51+
codesign --verify --strict ./browserstack-cli && codesign -dv ./browserstack-cli 2>&1 | grep TeamIdentifier
52+
```
53+
54+
- **Windows** (PowerShell): `Status` must be `Valid` and the signer must be BrowserStack.
55+
56+
```powershell
57+
Get-AuthenticodeSignature .\browserstack-cli.exe | Format-List Status, SignerCertificate
58+
```
59+
60+
If the check fails, do not run the binary.
61+
62+
5. **Run tests using BrowserStack CLI**
4563

4664
```sh
4765
./browserstack-cli load run
4866
```
4967

50-
5. **View Test Results**
68+
6. **View Test Results**
5169

5270
Visit the [BrowserStack Load-Testing Dashboard](https://load.browserstack.com/projects) to monitor and analyze your test runs.
5371

‎jest/browserstack-load.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# =============================
22
# Set BrowserStack Credentials
33
# =============================
4-
# Add your BrowserStack userName and accessKey here or set BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY as env variables.
4+
# Set BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY as env variables. They override the placeholders below.
5+
# Do not paste your real access key into this file: it is easy to commit and push by mistake.
56
userName: BROWSERSTACK_USERNAME
67
accessKey: BROWSERSTACK_ACCESS_KEY
78

0 commit comments

Comments
 (0)