Compare commits

..

1 Commits

Author SHA1 Message Date
Mo
8b6cfed6fa chore: autogenerated codeql file 2022-06-28 07:22:30 -05:00
9 changed files with 109 additions and 89 deletions

72
.github/workflows/codeql-analysis.yml vendored Normal file
View File

@@ -0,0 +1,72 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
schedule:
- cron: '44 8 * * 2'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

View File

@@ -3,12 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.3.2](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.3.1...@standardnotes/api-gateway@1.3.2) (2022-06-28)
### Bug Fixes
* checking for html content-type ([4a430b2](https://github.com/standardnotes/api-gateway/commit/4a430b2701733358d14da64a5eaa4e03620033e0))
## [1.3.1](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.3.0...@standardnotes/api-gateway@1.3.1) (2022-06-28)
### Bug Fixes

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/api-gateway",
"version": "1.3.2",
"version": "1.3.1",
"engines": {
"node": ">=16.0.0 <17.0.0"
},

View File

@@ -220,10 +220,7 @@ export class HttpService implements HttpServiceInterface {
}
private responseShouldNotBeDecorated(serviceResponse: AxiosResponse): boolean {
return (
serviceResponse.headers['content-type'] !== undefined &&
serviceResponse.headers['content-type'].toLowerCase().includes('text/html')
)
return serviceResponse.headers['content-type'].toLowerCase().includes('text/html')
}
private applyResponseHeaders(serviceResponse: AxiosResponse, response: Response): void {

View File

@@ -3,42 +3,6 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.3.10](https://github.com/standardnotes/auth/compare/@standardnotes/auth-server@1.3.9...@standardnotes/auth-server@1.3.10) (2022-06-30)
### Bug Fixes
* adjust callback in processing email campaigns ([26f8b75](https://github.com/standardnotes/auth/commit/26f8b75bede4d9bf05940f1d56ca85aa55ff3788))
## [1.3.9](https://github.com/standardnotes/auth/compare/@standardnotes/auth-server@1.3.8...@standardnotes/auth-server@1.3.9) (2022-06-29)
### Bug Fixes
* wrap processing email campaigns into try-catch ([997ffc0](https://github.com/standardnotes/auth/commit/997ffc02a35244f8d8536e5ee07e91228a708e71))
## [1.3.8](https://github.com/standardnotes/auth/compare/@standardnotes/auth-server@1.3.7...@standardnotes/auth-server@1.3.8) (2022-06-29)
### Bug Fixes
* temporarily send email campaings only for users without the mute_marketing_emails setting ([57694bd](https://github.com/standardnotes/auth/commit/57694bdc1412b91c48d07e264584bd3aab1d941b))
## [1.3.7](https://github.com/standardnotes/auth/compare/@standardnotes/auth-server@1.3.6...@standardnotes/auth-server@1.3.7) (2022-06-29)
### Bug Fixes
* setting encryption version when muting marketing emails ([37e21f6](https://github.com/standardnotes/auth/commit/37e21f6505de1b99bcc46b0700301e30d574bad5))
## [1.3.6](https://github.com/standardnotes/auth/compare/@standardnotes/auth-server@1.3.5...@standardnotes/auth-server@1.3.6) (2022-06-29)
### Bug Fixes
* mute marketing value encryption version setting ([1d4bce7](https://github.com/standardnotes/auth/commit/1d4bce73098e77076b8d78b575582452e8a5f94d))
## [1.3.5](https://github.com/standardnotes/auth/compare/@standardnotes/auth-server@1.3.4...@standardnotes/auth-server@1.3.5) (2022-06-29)
### Bug Fixes
* add logs for processing email campaigns ([2e92553](https://github.com/standardnotes/auth/commit/2e9255344eeb68375a78020e5888c056c850c5e5))
## [1.3.4](https://github.com/standardnotes/auth/compare/@standardnotes/auth-server@1.3.3...@standardnotes/auth-server@1.3.4) (2022-06-28)
**Note:** Version bump only for package @standardnotes/auth-server

View File

@@ -32,7 +32,6 @@ const sendEmailCampaign = async (
timer: TimerInterface,
domainEventFactory: DomainEventFactoryInterface,
domainEventPublisher: DomainEventPublisherInterface,
logger: Logger,
): Promise<void> => {
const stream = await userRepository.streamAll()
@@ -42,18 +41,12 @@ const sendEmailCampaign = async (
new Stream.Transform({
objectMode: true,
transform: async (rawUserData, _encoding, callback) => {
try {
let emailsMutedSetting = await settingService.findSettingWithDecryptedValue({
userUuid: rawUserData.user_uuid,
settingName: SettingName.MuteMarketingEmails,
})
if (emailsMutedSetting !== null) {
callback()
return
}
let emailsMutedSetting = await settingService.findSettingWithDecryptedValue({
userUuid: rawUserData.user_uuid,
settingName: SettingName.MuteMarketingEmails,
})
if (emailsMutedSetting === null) {
const user = (await userRepository.findOneByUuid(rawUserData.user_uuid)) as User
const { setting } = await settingService.createOrReplace({
@@ -61,37 +54,41 @@ const sendEmailCampaign = async (
props: {
name: SettingName.MuteMarketingEmails,
unencryptedValue: MuteMarketingEmailsOption.NotMuted,
serverEncryptionVersion: EncryptionVersion.Unencrypted,
serverEncryptionVersion: EncryptionVersion.Default,
sensitive: false,
},
})
emailsMutedSetting = setting
let activeSubscription = false
let subscriptionPlanName = null
const userSubscription = await userSubscriptionRepository.findOneByUserUuid(rawUserData.user_uuid)
if (userSubscription !== null) {
activeSubscription =
!userSubscription.cancelled && userSubscription.endsAt > timer.getTimestampInMicroseconds()
subscriptionPlanName = userSubscription.planName
}
await domainEventPublisher.publish(
domainEventFactory.createEmailMessageRequestedEvent({
userEmail: rawUserData.user_email,
messageIdentifier: emailMessageIdentifier as EmailMessageIdentifier,
context: {
activeSubscription,
subscriptionPlanName,
muteEmailsSettingUuid: emailsMutedSetting.uuid,
},
}),
)
} catch (error) {
logger.error(`Could not process user ${rawUserData.user_uuid}: ${(error as Error).message}`)
}
if (emailsMutedSetting.value === MuteMarketingEmailsOption.Muted) {
callback()
return
}
let activeSubscription = false
let subscriptionPlanName = null
const userSubscription = await userSubscriptionRepository.findOneByUserUuid(rawUserData.user_uuid)
if (userSubscription !== null) {
activeSubscription =
!userSubscription.cancelled && userSubscription.endsAt > timer.getTimestampInMicroseconds()
subscriptionPlanName = userSubscription.planName
}
await domainEventPublisher.publish(
domainEventFactory.createEmailMessageRequestedEvent({
userEmail: rawUserData.user_email,
messageIdentifier: emailMessageIdentifier as EmailMessageIdentifier,
context: {
activeSubscription,
subscriptionPlanName,
muteEmailsSettingUuid: emailsMutedSetting.uuid,
},
}),
)
callback()
},
}),
@@ -135,7 +132,6 @@ void container.load().then((container) => {
timer,
domainEventFactory,
domainEventPublisher,
logger,
),
)
.then(() => {

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/auth-server",
"version": "1.3.10",
"version": "1.3.4",
"engines": {
"node": ">=16.0.0 <17.0.0"
},

View File

@@ -34,7 +34,6 @@ describe('MuteMarketingEmails', () => {
expect(settingRepository.save).toHaveBeenCalledWith({
value: 'muted',
serverEncryptionVersion: 0,
})
})
})

View File

@@ -1,7 +1,6 @@
import { MuteMarketingEmailsOption, SettingName } from '@standardnotes/settings'
import { inject, injectable } from 'inversify'
import TYPES from '../../../Bootstrap/Types'
import { EncryptionVersion } from '../../Encryption/EncryptionVersion'
import { SettingRepositoryInterface } from '../../Setting/SettingRepositoryInterface'
import { UseCaseInterface } from '../UseCaseInterface'
import { MuteMarketingEmailsDTO } from './MuteMarketingEmailsDTO'
@@ -24,7 +23,6 @@ export class MuteMarketingEmails implements UseCaseInterface {
}
setting.value = MuteMarketingEmailsOption.Muted
setting.serverEncryptionVersion = EncryptionVersion.Unencrypted
await this.settingRepository.save(setting)