From d705e83ac4738dc9b36a1e5da8a5534c94a8e489 Mon Sep 17 00:00:00 2001 From: sjoshi10 Date: Tue, 19 Mar 2019 11:42:26 -0400 Subject: [PATCH 01/10] Update package.json --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index eb372906..b7aa016a 100644 --- a/package.json +++ b/package.json @@ -63,6 +63,7 @@ "md5-file": "^4.0.0", "rimraf": "^2.6.2", "shell-quote": "^1.6.1" + "sha256-file": "1.0.0" }, "eslintConfig": { "extends": "eslint:recommended", From 67306440bd3451368528f02b11155bc8e022cb27 Mon Sep 17 00:00:00 2001 From: sjoshi10 Date: Tue, 19 Mar 2019 11:43:30 -0400 Subject: [PATCH 02/10] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b7aa016a..c9625698 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "lodash.values": "^4.3.0", "md5-file": "^4.0.0", "rimraf": "^2.6.2", - "shell-quote": "^1.6.1" + "shell-quote": "^1.6.1", "sha256-file": "1.0.0" }, "eslintConfig": { From 4a4ee4de772a851854b65df85bdd41be945e8d23 Mon Sep 17 00:00:00 2001 From: sjoshi10 Date: Tue, 19 Mar 2019 11:45:49 -0400 Subject: [PATCH 03/10] Update shared.js --- lib/shared.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/shared.js b/lib/shared.js index fe48e0e0..b36fd7e3 100644 --- a/lib/shared.js +++ b/lib/shared.js @@ -1,9 +1,11 @@ const Appdir = require('appdirectory'); const rimraf = require('rimraf'); -const md5File = require('md5-file'); +//const md5File = require('md5-file'); const glob = require('glob-all'); const path = require('path'); const fse = require('fs-extra'); +const sha256File = require('sha256-file'); + /** * This helper will check if we're using static cache and have max @@ -101,7 +103,7 @@ function getUserCachePath(options) { * @return {string} */ function md5Path(fullpath) { - return md5File.sync(fullpath); + return sha256File(fullpath); } module.exports = { From be395cd2a7a36e50994949aaceed747f504efd7b Mon Sep 17 00:00:00 2001 From: sjoshi10 Date: Tue, 19 Mar 2019 12:00:55 -0400 Subject: [PATCH 04/10] Update pip.js use sha256 instead of md5 --- lib/pip.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pip.js b/lib/pip.js index df107e23..3da432af 100644 --- a/lib/pip.js +++ b/lib/pip.js @@ -9,7 +9,7 @@ const { buildImage, getBindPath, getDockerUid } = require('./docker'); const { getStripCommand, getStripMode, deleteFiles } = require('./slim'); const { checkForAndDeleteMaxCacheVersions, - md5Path, + sha256Path, getRequirementsWorkingPath, getUserCachePath } = require('./shared'); @@ -474,7 +474,7 @@ function installRequirementsIfNeeded( } // Then generate our MD5 Sum of this requirements file to determine where it should "go" to and/or pull cache from - const reqChecksum = md5Path(slsReqsTxt); + const reqChecksum = sha256Path(slsReqsTxt); // Then figure out where this cache should be, if we're caching, if we're in a module, etc const workingReqsFolder = getRequirementsWorkingPath( From ae88c3de5b121b5934f14ee122aa77944ddf7a15 Mon Sep 17 00:00:00 2001 From: sjoshi10 Date: Tue, 19 Mar 2019 12:01:44 -0400 Subject: [PATCH 05/10] use sha256 instead of md5 --- lib/shared.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/shared.js b/lib/shared.js index b36fd7e3..1f8db9db 100644 --- a/lib/shared.js +++ b/lib/shared.js @@ -1,6 +1,5 @@ const Appdir = require('appdirectory'); const rimraf = require('rimraf'); -//const md5File = require('md5-file'); const glob = require('glob-all'); const path = require('path'); const fse = require('fs-extra'); @@ -102,7 +101,7 @@ function getUserCachePath(options) { * @param {string} fullpath * @return {string} */ -function md5Path(fullpath) { +function sha256Path(fullpath) { return sha256File(fullpath); } From b003462dd4a1d48e6d4bf90ce421f4d0b0912e0b Mon Sep 17 00:00:00 2001 From: sjoshi10 Date: Tue, 19 Mar 2019 12:02:10 -0400 Subject: [PATCH 06/10] Update shared.js --- lib/shared.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/shared.js b/lib/shared.js index 1f8db9db..4c3ef558 100644 --- a/lib/shared.js +++ b/lib/shared.js @@ -5,7 +5,6 @@ const path = require('path'); const fse = require('fs-extra'); const sha256File = require('sha256-file'); - /** * This helper will check if we're using static cache and have max * versions enabled and will delete older versions in a fifo fashion From 072caa13252db11c94ec81fd087ab40f0125b75c Mon Sep 17 00:00:00 2001 From: sjoshi10 Date: Tue, 19 Mar 2019 12:02:41 -0400 Subject: [PATCH 07/10] remove md5 --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index c9625698..1178d436 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,6 @@ "lodash.set": "^4.3.2", "lodash.uniqby": "^4.0.0", "lodash.values": "^4.3.0", - "md5-file": "^4.0.0", "rimraf": "^2.6.2", "shell-quote": "^1.6.1", "sha256-file": "1.0.0" From ae938b7c0947ca408cc6158ea1bd150bf635f67f Mon Sep 17 00:00:00 2001 From: sjoshi10 Date: Tue, 19 Mar 2019 12:18:02 -0400 Subject: [PATCH 08/10] update test to use sh256 --- test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test.js b/test.js index 08dd3f68..7855ef47 100644 --- a/test.js +++ b/test.js @@ -14,7 +14,7 @@ const { const { quote } = require('shell-quote'); const { sep } = require('path'); -const { getUserCachePath, md5Path } = require('./lib/shared'); +const { getUserCachePath, sha256Path } = require('./lib/shared'); const initialWorkingDir = process.cwd(); @@ -1679,7 +1679,7 @@ test('py3.6 uses static and download cache', t => { npm(['i', path]); sls(['--useDownloadCache=true', '--useStaticCache=true', 'package']); const cachepath = getUserCachePath(); - const cacheFolderHash = md5Path('.serverless/requirements.txt'); + const cacheFolderHash = sha256Path('.serverless/requirements.txt'); t.true( pathExistsSync(`${cachepath}${sep}downloadCacheslspyc${sep}http`), 'http exists in download-cache' From 8197c759f8a1c3141b05e3bd5c6d40f7a22c4b7c Mon Sep 17 00:00:00 2001 From: sjoshi10 Date: Tue, 19 Mar 2019 12:22:23 -0400 Subject: [PATCH 09/10] remove md5 --- test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test.js b/test.js index 7855ef47..2ec71976 100644 --- a/test.js +++ b/test.js @@ -1704,7 +1704,7 @@ test( 'package' ]); const cachepath = getUserCachePath(); - const cacheFolderHash = md5Path('.serverless/requirements.txt'); + const cacheFolderHash = sha256Path('.serverless/requirements.txt'); t.true( pathExistsSync(`${cachepath}${sep}downloadCacheslspyc${sep}http`), 'http exists in download-cache' @@ -1724,7 +1724,7 @@ test('py3.6 uses static cache', t => { npm(['i', path]); sls(['--useStaticCache=true', 'package']); const cachepath = getUserCachePath(); - const cacheFolderHash = md5Path('.serverless/requirements.txt'); + const cacheFolderHash = sha256Path('.serverless/requirements.txt'); t.true( pathExistsSync(`${cachepath}${sep}${cacheFolderHash}_slspyc${sep}flask`), 'flask exists in static-cache' @@ -1758,7 +1758,7 @@ test('py3.6 uses static cache with cacheLocation option', t => { npm(['i', path]); const cachepath = '.requirements-cache'; sls(['--useStaticCache=true', `--cacheLocation=${cachepath}`, 'package']); - const cacheFolderHash = md5Path('.serverless/requirements.txt'); + const cacheFolderHash = sha256Path('.serverless/requirements.txt'); t.true( pathExistsSync(`${cachepath}${sep}${cacheFolderHash}_slspyc${sep}flask`), 'flask exists in static-cache' @@ -1785,7 +1785,7 @@ test( 'package' ]); const cachepath = getUserCachePath(); - const cacheFolderHash = md5Path('.serverless/requirements.txt'); + const cacheFolderHash = sha256Path('.serverless/requirements.txt'); t.true( pathExistsSync(`${cachepath}${sep}${cacheFolderHash}_slspyc${sep}flask`), 'flask exists in static-cache' From 51e2e78c7e2f5b390d09766a45940542025d47df Mon Sep 17 00:00:00 2001 From: sjoshi10 Date: Tue, 19 Mar 2019 12:25:02 -0400 Subject: [PATCH 10/10] export sha256Path module --- lib/shared.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/shared.js b/lib/shared.js index 4c3ef558..34f61eb2 100644 --- a/lib/shared.js +++ b/lib/shared.js @@ -108,5 +108,5 @@ module.exports = { checkForAndDeleteMaxCacheVersions, getRequirementsWorkingPath, getUserCachePath, - md5Path + sha256Path };