Skip to content

Commit

Permalink
[AB#47252] fix various CVEs by bumping dependencies (#156)
Browse files Browse the repository at this point in the history
* fix: various CVEs

* feat: rate limiting

* chore: updated dependabot config

* fix: pr name validation pipeline
  • Loading branch information
BenjaminSchwendner authored Feb 7, 2025
1 parent 225cbd9 commit c169160
Show file tree
Hide file tree
Showing 10 changed files with 3,326 additions and 1,413 deletions.
7 changes: 6 additions & 1 deletion .adops/pr-name-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ pr:
include:
- main

variables:
- group: github-automation

jobs:
- job: VerifyPrName
pool:
Expand All @@ -19,6 +22,8 @@ jobs:
echo "Pull Request Number: $prNumber"
repoUrl=$(System.PullRequest.SourceRepositoryURI)
# remove .git from repoUrl if present (when raising PRs from vscode, this can happen)
repoUrl="${repoUrl%.git}"
# extract org and repo name from repoUrl
orgRepo=$(echo "$repoUrl" | sed -e 's/.*github.com\/\(.*\)/\1/')
Expand All @@ -43,5 +48,5 @@ jobs:
exit 1
fi
env:
GITHUB_TOKEN: $(GITHUB_TOKEN)
GITHUB_TOKEN: $(GH_TOKEN) # from the variable group
displayName: 'Verify Pull Request Name'
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
target-branch: "dev"
open-pull-requests-limit: 0
- package-ecosystem: "docker" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
target-branch: "dev"
open-pull-requests-limit: 0
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"build:payment-frontend:prod": "yarn && wsrun -trm -p frontend-service -c build && yarn install --prod"
},
"devDependencies": {
"@axinom/mosaic-cli": "0.18.4",
"@axinom/mosaic-cli": "^0.41.0",
"@types/jest": "^29.5.1",
"@types/node": "^18.14.1",
"@typescript-eslint/eslint-plugin": "^5.59.5",
Expand Down
8 changes: 4 additions & 4 deletions services/frontend-service/service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"token": "yarn util:load-vars ts-node --files -r dotenv/config scripts/end-user-token.ts"
},
"dependencies": {
"@axinom/mosaic-id-guard": "0.22.0",
"@axinom/mosaic-id-link-be": "0.13.8",
"@axinom/mosaic-service-common": "0.39.0",
"@axinom/mosaic-id-guard": "0.40.0",
"@axinom/mosaic-id-link-be": "0.29.0",
"@axinom/mosaic-service-common": "0.57.0",
"dotenv": "^16.0.3",
"env-var": "^7.3.0",
"express": "^4.18.2",
Expand All @@ -52,4 +52,4 @@
"ts-node": "^10.9.1",
"tsc-watch": "^6.0.4"
}
}
}
11 changes: 6 additions & 5 deletions services/payment-connector/service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@
"codegen": "yarn util:load-vars graphql-codegen --config codegen.yml"
},
"dependencies": {
"@axinom/mosaic-id-guard": "0.22.0",
"@axinom/mosaic-id-link-be": "0.13.8",
"@axinom/mosaic-service-common": "0.39.0",
"@axinom/mosaic-id-guard": "0.40.0",
"@axinom/mosaic-id-link-be": "0.29.0",
"@axinom/mosaic-service-common": "0.57.0",
"ajv": "^8.12.0",
"cors": "^2.8.5",
"dotenv": "^16.0.3",
"env-cmd": "^10.1.0",
"env-var": "^7.3.0",
"express": "^4.18.2",
"express-rate-limit": "^7.5.0",
"graphile-build": "^4.13.0",
"graphile-build-pg": "^4.13.0",
"graphile-utils": "4.13.0",
Expand All @@ -50,7 +51,7 @@
},
"devDependencies": {
"@babel/core": "^7.0.0-0",
"@graphql-codegen/cli": "^3.2.0",
"@graphql-codegen/cli": "^4.0.1",
"@graphql-codegen/typescript": "^3.0.1",
"@graphql-codegen/typescript-graphql-request": "^4.5.8",
"@graphql-codegen/typescript-operations": "^3.0.1",
Expand All @@ -77,4 +78,4 @@
"tsc-watch": "^6.0.4",
"typescript": "^4.9.5"
}
}
}
35 changes: 14 additions & 21 deletions services/payment-connector/service/src/generated/graphql/billing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,6 @@ export type DeletePaymentProviderPayload = {
* unchanged and unused. May be used by a client to track mutations.
*/
clientMutationId?: Maybe<Scalars['String']>;
deletedPaymentProviderNodeId?: Maybe<Scalars['ID']>;
/** The `PaymentProvider` that was deleted by this mutation. */
paymentProvider?: Maybe<PaymentProvider>;
/** An edge for our `PaymentProvider`. May be used by Relay 1. */
Expand Down Expand Up @@ -451,7 +450,6 @@ export type DeletePaypalSettingPayload = {
* unchanged and unused. May be used by a client to track mutations.
*/
clientMutationId?: Maybe<Scalars['String']>;
deletedPaypalSettingNodeId?: Maybe<Scalars['ID']>;
/** Reads a single `PaymentProvider` that is related to this `PaypalSetting`. */
paymentProvider?: Maybe<PaymentProvider>;
/** The `PaypalSetting` that was deleted by this mutation. */
Expand Down Expand Up @@ -1075,7 +1073,6 @@ export type Mutation = {
deletePaymentProvider?: Maybe<DeletePaymentProviderPayload>;
/** Deletes a single `PaypalSetting` using a unique key. */
deletePaypalSetting?: Maybe<DeletePaypalSettingPayload>;
populateSubscriptions?: Maybe<PopulatePayload>;
setSettings?: Maybe<SetSettingsPayload>;
/** Updates a single `PaymentProvider` using a unique key and a patch. */
updatePaymentProvider?: Maybe<UpdatePaymentProviderPayload>;
Expand Down Expand Up @@ -1124,12 +1121,6 @@ export type MutationDeletePaypalSettingArgs = {
};


/** The root mutation type which contains root level fields which mutate data. */
export type MutationPopulateSubscriptionsArgs = {
input: PopulateInput;
};


/** The root mutation type which contains root level fields which mutate data. */
export type MutationSetSettingsArgs = {
input: SetSettingsInput;
Expand Down Expand Up @@ -1997,18 +1988,6 @@ export type PeriodUnitFilter = {
notIn?: InputMaybe<Array<PeriodUnit>>;
};

export type PopulateInput = {
count: Scalars['Int'];
includeStatusChanges?: InputMaybe<Scalars['Boolean']>;
includeTransactions?: InputMaybe<Scalars['Boolean']>;
};

export type PopulatePayload = {
__typename?: 'PopulatePayload';
count: Scalars['Int'];
query?: Maybe<Query>;
};

/** The root query type which gives access points into the data universe. */
export type Query = {
__typename?: 'Query';
Expand Down Expand Up @@ -3354,9 +3333,23 @@ export type SubscriptionTypeFilter = {
userId?: InputMaybe<UuidFilter>;
};

export enum SubscriptionTypeSubscriptionEventKey {
SubscriptionChanged = 'SUBSCRIPTION_CHANGED',
SubscriptionCreated = 'SUBSCRIPTION_CREATED',
SubscriptionDeleted = 'SUBSCRIPTION_DELETED',
SubscriptionStatusChangeChanged = 'SUBSCRIPTION_STATUS_CHANGE_CHANGED',
SubscriptionStatusChangeCreated = 'SUBSCRIPTION_STATUS_CHANGE_CREATED',
SubscriptionStatusChangeDeleted = 'SUBSCRIPTION_STATUS_CHANGE_DELETED',
SubscriptionTransactionChanged = 'SUBSCRIPTION_TRANSACTION_CHANGED',
SubscriptionTransactionCreated = 'SUBSCRIPTION_TRANSACTION_CREATED',
SubscriptionTransactionDeleted = 'SUBSCRIPTION_TRANSACTION_DELETED'
}

export type SubscriptionTypeSubscriptionPayload = {
__typename?: 'SubscriptionTypeSubscriptionPayload';
/** @deprecated Use 'eventKey' instead. */
event?: Maybe<Scalars['String']>;
eventKey?: Maybe<SubscriptionTypeSubscriptionEventKey>;
id: Scalars['UUID'];
subscription?: Maybe<SubscriptionType>;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { assertError, Logger } from '@axinom/mosaic-service-common';
import cors from 'cors';
import { Application, Request, Response } from 'express';
import { Config, parseAuthenticationTokenValue } from '../common';
import { limiter } from './rate-limit';
import { getStripe } from './stripe-init';

/**
Expand Down Expand Up @@ -52,6 +53,6 @@ export const customerOverviewRoute = (
res.status(400).send([]);
}
};
app.get('/customer-overview', [cors(), customerOverviewMiddleware]);
app.get('/customer-overview', [cors(), limiter, customerOverviewMiddleware]);
app.options('/customer-overview', [cors()]);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import rateLimit from 'express-rate-limit';

export const limiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100, // limit each IP to 100 requests per windowMs
message: 'Too many requests from this IP, please try again after 15 minutes',
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Application, json, Request, Response } from 'express';
import { Config, parseAuthenticationTokenValue } from '../common';
import { getMosaicBillingClient } from '../mosaic-domain';
import { ensureCustomerExists } from './ensure-customer-exists';
import { limiter } from './rate-limit';
import { getStripe } from './stripe-init';

/**
Expand Down Expand Up @@ -73,6 +74,11 @@ export const startCheckoutRoute = (app: Application, config: Config): void => {
res.status(400).send({ subscriptionId: null, redirectUrl: null });
}
};
app.post('/start-checkout', [json(), cors(), startCheckoutMiddleware]);
app.post('/start-checkout', [
json(),
cors(),
limiter,
startCheckoutMiddleware,
]);
app.options('/start-checkout', [cors()]);
};
Loading

0 comments on commit c169160

Please sign in to comment.