-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Julio A.
authored
Oct 15, 2024
1 parent
5cc9ac5
commit e14fa89
Showing
11 changed files
with
133 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@rocket.chat/meteor': patch | ||
--- | ||
|
||
Security Hotfix (https://docs.rocket.chat/docs/security-fixes-and-updates) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
apps/meteor/app/lib/server/functions/disableCustomScripts.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { License } from '@rocket.chat/license'; | ||
|
||
export const disableCustomScripts = () => { | ||
const license = License.getLicense(); | ||
|
||
if (!license) { | ||
return false; | ||
} | ||
|
||
const isCustomScriptDisabled = process.env.DISABLE_CUSTOM_SCRIPTS === 'true'; | ||
const isTrialLicense = license?.information.trial; | ||
|
||
return isCustomScriptDisabled && isTrialLicense; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
apps/meteor/tests/unit/app/lib/server/functions/disableCustomScripts.tests.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { expect } from 'chai'; | ||
import proxyquire from 'proxyquire'; | ||
import sinon from 'sinon'; | ||
|
||
describe('disableCustomScripts', () => { | ||
let mockLicense: sinon.SinonStubbedInstance<any>; | ||
let disableCustomScripts: () => boolean; | ||
let disableCustomScriptsVar: any; | ||
|
||
beforeEach(() => { | ||
disableCustomScriptsVar = process.env.DISABLE_CUSTOM_SCRIPTS; | ||
mockLicense = { | ||
getLicense: sinon.stub(), | ||
}; | ||
|
||
disableCustomScripts = proxyquire('../../../../../../app/lib/server/functions/disableCustomScripts.ts', { | ||
'@rocket.chat/license': { License: mockLicense }, | ||
}).disableCustomScripts; | ||
}); | ||
|
||
afterEach(() => { | ||
process.env.DISABLE_CUSTOM_SCRIPTS = disableCustomScriptsVar; | ||
sinon.restore(); | ||
}); | ||
|
||
it('should return false when license is missing', () => { | ||
mockLicense.getLicense.returns(null); | ||
|
||
const result = disableCustomScripts(); | ||
expect(result).to.be.false; | ||
}); | ||
|
||
it('should return false when DISABLE_CUSTOM_SCRIPTS is not true', () => { | ||
mockLicense.getLicense.returns({ | ||
information: { | ||
trial: true, | ||
}, | ||
}); | ||
|
||
const result = disableCustomScripts(); | ||
expect(result).to.be.false; | ||
}); | ||
|
||
it('should return false when license is not a trial', () => { | ||
mockLicense.getLicense.returns({ | ||
information: { | ||
trial: false, | ||
}, | ||
}); | ||
|
||
process.env.DISABLE_CUSTOM_SCRIPTS = 'true'; | ||
|
||
const result = disableCustomScripts(); | ||
expect(result).to.be.false; | ||
}); | ||
|
||
it('should return true when DISABLE_CUSTOM_SCRIPTS is true and license is a trial', () => { | ||
mockLicense.getLicense.returns({ | ||
information: { | ||
trial: true, | ||
}, | ||
}); | ||
|
||
process.env.DISABLE_CUSTOM_SCRIPTS = 'true'; | ||
|
||
const result = disableCustomScripts(); | ||
expect(result).to.be.true; | ||
}); | ||
}); |