Skip to content

Commit

Permalink
fix: remove d2 config author/organisation name check (#496)
Browse files Browse the repository at this point in the history
* fix: remove d2 config author/organisation name check

* fix: remove manifest author/organisation name check
  • Loading branch information
mediremi authored May 27, 2021
1 parent a188979 commit 6ccaf07
Showing 1 changed file with 5 additions and 35 deletions.
40 changes: 5 additions & 35 deletions server/src/security/verifyBundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@ const isValidJSON = json => {
}
}

const checkManifest = ({
manifest,
appId,
appName,
version,
organisationName,
canBeCoreApp
}) => {
const checkManifest = ({ manifest, appId, appName, version, canBeCoreApp }) => {
if (manifest.app_hub_id && manifest.app_hub_id !== appId) {
throw new Error('Manifest App Hub ID does not match app ID')
}
Expand All @@ -26,23 +19,12 @@ const checkManifest = ({
if (manifest.version !== version) {
throw new Error('Manifest version does not match app version')
}
const manifestDeveloper = manifest.developer?.name
if (manifestDeveloper && manifestDeveloper !== organisationName) {
throw new Error('Manifest developer does not match app organisation')
}
if (!canBeCoreApp && manifest.core_app) {
throw new Error('Manifest incorrectly declares app as core app')
}
}

const checkD2Config = ({
d2Config,
appId,
appName,
version,
organisationName,
canBeCoreApp
}) => {
const checkD2Config = ({ d2Config, appId, appName, version, canBeCoreApp }) => {
if (d2Config.id && d2Config.id !== appId) {
throw new Error('D2 config App Hub ID does not match app ID')
}
Expand All @@ -52,22 +34,12 @@ const checkD2Config = ({
if (d2Config.version !== version) {
throw new Error('D2 config version does not match app version')
}
const d2ConfigDeveloper = d2Config.author?.name
if (d2ConfigDeveloper && d2ConfigDeveloper !== organisationName) {
throw new Error('D2 config developer does not match app organisation')
}
if (!canBeCoreApp && d2Config.coreApp) {
throw new Error('D2 config incorrectly declares app as core app')
}
}

module.exports = ({
buffer,
appId,
appName,
version,
organisationName,
}) => {
module.exports = ({ buffer, appId, appName, version, organisationName }) => {
const zip = new AdmZip(buffer)
const entries = zip.getEntries().map(e => e.entryName)
const manifestPath = 'manifest.webapp'
Expand All @@ -87,8 +59,7 @@ module.exports = ({
appId,
appName,
version,
organisationName,
canBeCoreApp
canBeCoreApp,
})

// D2 config is optional
Expand All @@ -105,7 +76,6 @@ module.exports = ({
appId,
appName,
version,
organisationName,
canBeCoreApp
canBeCoreApp,
})
}

0 comments on commit 6ccaf07

Please sign in to comment.