Skip to content

Commit e636009

Browse files
authored
Merge branch 'main' into add-email-to-update-user
2 parents b04b94e + 1f9932d commit e636009

File tree

83 files changed

+1855
-240
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1855
-240
lines changed

.github/workflows/coana-analysis.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,27 @@ name: Coana Vulnerability Analysis
22

33
on:
44
schedule:
5-
# every day at 12 AM
6-
- cron: '0 0 * * *'
5+
- cron: '0 3 * * *' # every day at 3 AM
76
workflow_dispatch:
87
inputs:
98
tags:
109
description: 'Manually run vulnerability analysis'
10+
# Required by the return-dispatch action
11+
distinct_id:
1112

1213
jobs:
1314
coana-vulnerability-analysis:
1415
runs-on: ubuntu-latest
15-
timeout-minutes: 60
1616

1717
steps:
1818
- name: Checkout code
1919
uses: actions/checkout@v4
20+
2021
- name: Run Coana CLI
2122
id: coana-cli
22-
run: |
23-
npx @coana-tech/cli run . \
24-
--api-key ${{ secrets.COANA_API_KEY }} \
25-
--repo-url https://github.com/${{github.repository}}
23+
uses: docker://coana/coana:latest@sha256:74144ed0fc9d7da87dcd45ccd12458cc7c25ad23e47eebd7ceb4860ed396d63e
24+
with:
25+
args: |
26+
coana run . \
27+
--api-key ${{ secrets.COANA_API_KEY }} \
28+
--repo-url https://github.com/${{github.repository}}

.github/workflows/coana-guardrail.yml

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,27 @@ on: pull_request
55
jobs:
66
guardrail:
77
runs-on: ubuntu-latest
8-
timeout-minutes: 15
8+
99
steps:
10-
- name: Get changed files
11-
id: changed-files
12-
uses: tj-actions/changed-files@v44
13-
with:
14-
separator: ' '
15-
1610
- name: Checkout the ${{github.base_ref}} branch
1711
uses: actions/checkout@v4
1812
with:
1913
ref: ${{github.base_ref}} # checkout the base branch (usually master/main).
20-
14+
15+
- name: Fetch the PR branch
16+
run: |
17+
git fetch ${{ github.event.pull_request.head.repo.clone_url }} ${{ github.head_ref }}:${{ github.head_ref }} --depth=1
18+
19+
- name: Get list of changed files relative to the main/master branch
20+
id: changed-files
21+
run: |
22+
echo "all_changed_files=$(git diff --name-only ${{ github.base_ref }} ${{ github.head_ref }} | tr '\n' ' ')" >> $GITHUB_OUTPUT
23+
2124
- name: Use Node.js 20.x
2225
uses: actions/setup-node@v4
2326
with:
2427
node-version: 20.x
25-
28+
2629
- name: Run Coana on the ${{github.base_ref}} branch
2730
run: |
2831
npx @coana-tech/cli run . \
@@ -31,16 +34,20 @@ jobs:
3134
-o /tmp/main-branch \
3235
--changed-files ${{ steps.changed-files.outputs.all_changed_files }} \
3336
--lightweight-reachability \
34-
35-
# Reset file permissions changed by Coana CLI.
37+
38+
# Reset file permissions.
39+
# This is necessary because the Coana CLI may add
40+
# new files with root ownership since it's using docker.
41+
# These files will not be deleted by the clean step in checkout
42+
# if the permissions are not reset.
3643
- name: Reset file permissions
3744
run: sudo chown -R $USER:$USER .
38-
45+
3946
- name: Checkout the current branch
4047
uses: actions/checkout@v4
4148
with:
4249
clean: true
43-
50+
4451
- name: Run Coana on the current branch
4552
run: |
4653
npx @coana-tech/cli run . \
@@ -49,12 +56,12 @@ jobs:
4956
-o /tmp/current-branch \
5057
--changed-files ${{ steps.changed-files.outputs.all_changed_files }} \
5158
--lightweight-reachability \
52-
59+
5360
- name: Run Report Comparison
5461
run: |
5562
npx @coana-tech/cli compare-reports \
5663
--api-key ${{ secrets.COANA_API_KEY || 'api-key-unavailable' }} \
5764
/tmp/main-branch/coana-report.json \
5865
/tmp/current-branch/coana-report.json
5966
env:
60-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "7.41.0",
2+
"version": "7.50.1",
33
"name": "@workos-inc/node",
44
"author": "WorkOS",
55
"description": "A Node wrapper for the WorkOS API",
@@ -40,6 +40,7 @@
4040
"dependencies": {
4141
"iron-session": "~6.3.1",
4242
"jose": "~5.6.3",
43+
"leb": "^1.0.0",
4344
"pluralize": "8.0.0"
4445
},
4546
"devDependencies": {

src/actions/actions.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import crypto from 'crypto';
22
import { WorkOS } from '../workos';
33
import mockAuthActionContext from './fixtures/authentication-action-context.json';
44
import mockUserRegistrationActionContext from './fixtures/user-registration-action-context.json';
5+
import { NodeCryptoProvider } from '../common/crypto/node-crypto-provider';
6+
57
const workos = new WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
6-
import { NodeCryptoProvider } from '../common/crypto/NodeCryptoProvider';
78

89
describe('Actions', () => {
910
let secret: string;
@@ -127,6 +128,7 @@ describe('Actions', () => {
127128
createdAt: '2024-10-22T17:12:50.746Z',
128129
updatedAt: '2024-10-22T17:12:50.746Z',
129130
externalId: null,
131+
metadata: {},
130132
},
131133
ipAddress: '50.141.123.10',
132134
userAgent: 'Mozilla/5.0',
@@ -142,6 +144,7 @@ describe('Actions', () => {
142144
createdAt: '2024-10-22T17:12:50.746Z',
143145
updatedAt: '2024-10-22T17:12:50.746Z',
144146
externalId: null,
147+
metadata: {},
145148
},
146149
organizationMembership: {
147150
object: 'organization_membership',

src/actions/actions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { SignatureProvider } from '../common/crypto/SignatureProvider';
21
import { CryptoProvider } from '../common/crypto/crypto-provider';
2+
import { SignatureProvider } from '../common/crypto/signature-provider';
33
import { unreachable } from '../common/utils/unreachable';
44
import { ActionContext, ActionPayload } from './interfaces/action.interface';
55
import {

src/common/crypto/CryptoProvider.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/common/crypto/NodeCryptoProvider.ts

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/common/crypto/SubtleCryptoProvider.ts

Lines changed: 0 additions & 89 deletions
This file was deleted.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import crypto from 'crypto';
2-
import { NodeCryptoProvider } from './NodeCryptoProvider';
3-
import { SubtleCryptoProvider } from './SubtleCryptoProvider';
2+
import { NodeCryptoProvider } from './node-crypto-provider';
3+
import { SubtleCryptoProvider } from './subtle-crypto-provider';
44
import mockWebhook from '../../webhooks/fixtures/webhook.json';
5-
import { SignatureProvider } from './SignatureProvider';
5+
import { SignatureProvider } from './signature-provider';
66

77
describe('CryptoProvider', () => {
88
let payload: any;

src/common/crypto/crypto-provider.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,51 @@ export abstract class CryptoProvider {
3535
* Cryptographically determine whether two signatures are equal
3636
*/
3737
abstract secureCompare(stringA: string, stringB: string): Promise<boolean>;
38+
39+
/**
40+
* Encrypts data using AES-256-GCM algorithm.
41+
*
42+
* @param plaintext The data to encrypt
43+
* @param key The encryption key (should be 32 bytes for AES-256)
44+
* @param iv Optional initialization vector (if not provided, a random one will be generated)
45+
* @param aad Optional additional authenticated data
46+
* @returns Object containing the encrypted ciphertext, the IV used, and the authentication tag
47+
*/
48+
abstract encrypt(
49+
plaintext: Uint8Array,
50+
key: Uint8Array,
51+
iv?: Uint8Array,
52+
aad?: Uint8Array,
53+
): Promise<{
54+
ciphertext: Uint8Array;
55+
iv: Uint8Array;
56+
tag: Uint8Array;
57+
}>;
58+
59+
/**
60+
* Decrypts data that was encrypted using AES-256-GCM algorithm.
61+
*
62+
* @param ciphertext The encrypted data
63+
* @param key The decryption key (must be the same key used for encryption)
64+
* @param iv The initialization vector used during encryption
65+
* @param tag The authentication tag produced during encryption
66+
* @param aad Optional additional authenticated data (must match what was used during encryption)
67+
* @returns The decrypted data
68+
* @throws Will throw an error if authentication fails or the data has been tampered with
69+
*/
70+
abstract decrypt(
71+
ciphertext: Uint8Array,
72+
key: Uint8Array,
73+
iv: Uint8Array,
74+
tag: Uint8Array,
75+
aad?: Uint8Array,
76+
): Promise<Uint8Array>;
77+
78+
/**
79+
* Generates cryptographically secure random bytes.
80+
*
81+
* @param length The number of random bytes to generate
82+
* @returns A Uint8Array containing the random bytes
83+
*/
84+
abstract randomBytes(length: number): Uint8Array;
3885
}

0 commit comments

Comments
 (0)