Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix code signing issue with diff package - keep .codepushrelease in m…
…anifest json but ignores it in package hash as it needs to be included in diff package
  • Loading branch information
rocwind committed Mar 16, 2019
commit a3b2080201779416e0125f86796521f481a1dd85
24 changes: 18 additions & 6 deletions core/utils/security.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ security.stringSha256Sync = function (contents) {

security.packageHashSync = function (jsonData) {
var sortedArr = security.sortJsonToArr(jsonData);
var manifestData = _.map(sortedArr, (v) => {
var manifestData = _.filter(sortedArr, (v) => {
return !security.isPackageHashIgnored(v.path);
}).map((v) => {
return v.path + ':' + v.hash;
});
log.debug('packageHashSync manifestData:', manifestData);
Expand Down Expand Up @@ -153,18 +155,28 @@ security.isHashIgnored = function (relativePath) {
return true;
}


const IgnoreMacOSX = '__MACOSX/';
const IgnoreDSStore = '.DS_Store';
const IgnoreCodePushMetadata = '.codepushrelease';

return relativePath.startsWith(IgnoreMacOSX)
|| relativePath === IgnoreDSStore
|| relativePath.endsWith(IgnoreDSStore)
|| relativePath === IgnoreCodePushMetadata
|| relativePath.endsWith(IgnoreCodePushMetadata);
|| relativePath.endsWith(IgnoreDSStore);
}

security.isPackageHashIgnored = function (relativePath) {
if (!relativePath) {
return true;
}

// .codepushrelease contains code sign JWT
// it should be ignored in package hash but need to be included in package manifest
const IgnoreCodePushMetadata = '.codepushrelease';
return relativePath === IgnoreCodePushMetadata
|| relativePath.endsWith(IgnoreCodePushMetadata)
|| security.isHashIgnored(relativePath);
}


security.calcAllFileSha256 = function (directoryPath) {
return new Promise((resolve, reject) => {
var recursive = require("recursive-readdir");
Expand Down