Skip to content

Commit 3489c47

Browse files
rocwindlisong
authored andcommitted
fix code signing issue with diff package - keep .codepushrelease in manifest json but ignores it in package hash as it needs to be included in diff package (lisong#184)
1 parent 6e6dcd5 commit 3489c47

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

core/utils/security.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ security.stringSha256Sync = function (contents) {
6161

6262
security.packageHashSync = function (jsonData) {
6363
var sortedArr = security.sortJsonToArr(jsonData);
64-
var manifestData = _.map(sortedArr, (v) => {
64+
var manifestData = _.filter(sortedArr, (v) => {
65+
return !security.isPackageHashIgnored(v.path);
66+
}).map((v) => {
6567
return v.path + ':' + v.hash;
6668
});
6769
log.debug('packageHashSync manifestData:', manifestData);
@@ -153,18 +155,28 @@ security.isHashIgnored = function (relativePath) {
153155
return true;
154156
}
155157

156-
157158
const IgnoreMacOSX = '__MACOSX/';
158159
const IgnoreDSStore = '.DS_Store';
159-
const IgnoreCodePushMetadata = '.codepushrelease';
160160

161161
return relativePath.startsWith(IgnoreMacOSX)
162162
|| relativePath === IgnoreDSStore
163-
|| relativePath.endsWith(IgnoreDSStore)
164-
|| relativePath === IgnoreCodePushMetadata
165-
|| relativePath.endsWith(IgnoreCodePushMetadata);
163+
|| relativePath.endsWith(IgnoreDSStore);
164+
}
165+
166+
security.isPackageHashIgnored = function (relativePath) {
167+
if (!relativePath) {
168+
return true;
169+
}
170+
171+
// .codepushrelease contains code sign JWT
172+
// it should be ignored in package hash but need to be included in package manifest
173+
const IgnoreCodePushMetadata = '.codepushrelease';
174+
return relativePath === IgnoreCodePushMetadata
175+
|| relativePath.endsWith(IgnoreCodePushMetadata)
176+
|| security.isHashIgnored(relativePath);
166177
}
167178

179+
168180
security.calcAllFileSha256 = function (directoryPath) {
169181
return new Promise((resolve, reject) => {
170182
var recursive = require("recursive-readdir");

0 commit comments

Comments
 (0)