-
-
Notifications
You must be signed in to change notification settings - Fork 32
👷 add upstream change detection #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| name: upstream | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| schedule: | ||
| - cron: "33 3 * * 3" # weekly | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| node-version: ['latest'] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Use Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| - run: npm install | ||
| - run: npm run upstream |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // NOTE: this is a temporary solution to tell us if future changes to the monkey-patched methods | ||
| // could impact this package. Recognizing this is not an ideal solution, we plan to address this when | ||
| // we can drop the monkey-patching entirely. | ||
| const crypto = require('crypto') | ||
| const assert = require('assert') | ||
| const http = require('http') | ||
| const Socket = require('net').Socket | ||
|
|
||
| const req = new http.IncomingMessage(new Socket()) | ||
| const res = new http.ServerResponse(req) | ||
|
|
||
| function getFunctionHash (fn) { | ||
| const src = fn.toString().replace(/\s+/g, '') // normalize whitespace | ||
| return crypto.createHash('sha256').update(src).digest('hex') | ||
| } | ||
|
|
||
| const knownWriteHeadHash = '281e0d02084a69893b8c3b8692e3c7c4de2ce22a626217fcf597fa6ddf6955a9' | ||
| const knownSetHeaderHash = '2d4f95e92586d28bfd4d3137a8eaacb82b255967d8c26413015c6b56daf0afe7' | ||
| const knownAppendHeaderHash = '0deb9f70c3bba63993321cca9281fb4607e2567bed1436b8574c5b86698125a8' | ||
| const knownRemoveHeaderHash = '3ad5ccb0a858beb6268f281492bd8d42c9815f5316cc3c4f7f735e142fcd29d9' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we add some automation to update these after a change is looked into? Just to make it easier than copy pasting the new value from the failed build?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, should be a straight-forward follow-on.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| describe('function verification', function () { | ||
| it('should match the known function hash of writeHead', function () { | ||
| const currentHash = getFunctionHash(res.writeHead) | ||
| assert.strictEqual(currentHash, knownWriteHeadHash, 'writeHead hash has changed') | ||
| }) | ||
|
|
||
| it('should match the known function hash of setHeader', function () { | ||
| const currentHash = getFunctionHash(res.setHeader) | ||
| assert.strictEqual(currentHash, knownSetHeaderHash, 'setHeader hash has changed') | ||
| }) | ||
|
|
||
| it('should match the known function hash of appendHeader', function () { | ||
| const currentHash = getFunctionHash(res.appendHeader) | ||
| assert.strictEqual(currentHash, knownAppendHeaderHash, 'appendHeader hash has changed') | ||
| }) | ||
|
|
||
| it('should match the known function hash of removeHeader', function () { | ||
| const currentHash = getFunctionHash(res.removeHeader) | ||
| assert.strictEqual(currentHash, knownRemoveHeaderHash, 'removeHeader hash has changed') | ||
| }) | ||
ctcpip marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }) | ||
Uh oh!
There was an error while loading. Please reload this page.