Socket
Socket
Sign inDemoInstall

@warren-bank/crx-header

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.2.0

72

bin/crx-header.js

@@ -31,45 +31,53 @@ #! /usr/bin/env node

} catch (error) {
console.log('ERROR:', 'filepath to input CRX must exist and be readable', "\n", filepath, "\n")
console.log('ERROR:', filepath)
console.log('ERROR:', 'filepath to input CRX must exist and be readable', "\n")
return // process next input filepath
}
const crxBuffer = fs.readFileSync(filepath, {encoding: null})
const crxReader = new CrxReader(crxBuffer)
const hexContents = crxReader.getContents('hex')
const b64Contents = crxReader.getContents('base64')
try {
const crxBuffer = fs.readFileSync(filepath, {encoding: null})
const crxReader = new CrxReader(crxBuffer)
const hexContents = crxReader.getContents('hex')
const b64Contents = crxReader.getContents('base64')
if (!counter) print_divider()
if (!counter) print_divider()
console.log('filename:')
console.log('=========')
console.log(filepath)
console.log()
console.log('filename:')
console.log('=========')
console.log(filepath)
console.log()
console.log('version = ', hexContents.version)
console.log('length of public key = ', hexContents.publicKeyLength)
console.log('length of signature = ', hexContents.signatureLength)
console.log()
console.log('version =', hexContents.version)
console.log('length of public key =', hexContents.publicKeyLength)
console.log('length of signature =', hexContents.signatureLength)
console.log()
console.log('public key (hex):')
console.log('=================')
console.log(hexContents.publicKey)
console.log()
console.log('public key (hex):')
console.log('=================')
console.log(hexContents.publicKey)
console.log()
console.log('public key (base64):')
console.log('====================')
console.log(b64Contents.publicKey)
console.log()
console.log('public key (base64):')
console.log('====================')
console.log(b64Contents.publicKey)
console.log()
console.log('signature (hex):')
console.log('=================')
console.log(hexContents.signature)
console.log()
console.log('signature (hex):')
console.log('=================')
console.log(hexContents.signature)
console.log()
console.log('signature (base64):')
console.log('====================')
console.log(b64Contents.signature)
console.log()
console.log('signature (base64):')
console.log('====================')
console.log(b64Contents.signature)
console.log()
print_divider()
counter++
print_divider()
counter++
}
catch (error) {
console.log('ERROR:', filepath)
console.log('ERROR:', error.message, "\n")
return // process next input filepath
}
})

@@ -76,0 +84,0 @@

@@ -53,2 +53,4 @@ var assert = require('assert');

verifyData(publicKey, signature, zipArchive)
return {magicNumber, version, publicKeyLength, signatureLength, publicKey, signature, zipArchive};

@@ -58,2 +60,27 @@ }

/**
* Verifies the CRX signature was generated with the public key.
*
* @param {Buffer} publicKey
* @param {Buffer} signature
* @param {Buffer} zipArchive
*/
function verifyData(publicKey, signature, zipArchive) {
const get_PEM_encoded_publicKey = function() {
let PEM = ''
PEM += '-----BEGIN PUBLIC KEY-----' + "\n"
PEM += publicKey.toString('base64') + "\n"
PEM += '-----END PUBLIC KEY-----'
return PEM
}
const verify = require('crypto').createVerify('SHA1')
verify.update(zipArchive)
if (! verify.verify(get_PEM_encoded_publicKey(), signature)) {
throw new Error('Not a valid CRX signature')
}
}
/**
* Return individual components of CRX file.

@@ -60,0 +87,0 @@ * Optionally encode binary data Buffers to format:

{
"name": "@warren-bank/crx-header",
"description": "Command-line tool to print information contained in the header of Chromium extension CRX files.",
"version": "0.1.0",
"version": "0.2.0",
"license": "GPL-2.0",

@@ -6,0 +6,0 @@ "scripts": {

@@ -0,0 +0,0 @@ ### [CRX header](https://github.com/warren-bank/crx-header/tree/nodejs)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc