Coder Social home page Coder Social logo

etcher-sdk's Introduction

etcher-sdk's People

Contributors

ab77 avatar acostach avatar aethernet avatar balena-ci avatar balena-renovate[bot] avatar brownjohnf avatar builder555 avatar dfunckt avatar dlech avatar flec avatar flowzone-app[bot] avatar forestjohnson avatar jakogut avatar jhermsmeier avatar jsreds avatar jviotti avatar kb2ma avatar klutchell avatar mcraa avatar page- avatar parthi-g avatar rcooke-warwick avatar renovate-bot avatar thgreasi avatar thundron avatar zrzka avatar zvin avatar zwhitchcox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

etcher-sdk's Issues

Prebuilt binaries for mountutils, drivelist and ext2fs

Hello.

I'm trying to install etcher-sdk into my Vue app bundled inside Electron.
Installation of package goes smoothly, but once electron-rebuild kicks in with installing prebuilt binaries and native dependencies, it comes with following errors:

• electron-builder  version=21.2.0
  • rebuilding native dependencies  [email protected]/[email protected], @ronomon/[email protected], [email protected], [email protected], [email protected], [email protected], [email protected] platform=linux arch=x64
  • install prebuilt binary  name=ext2fs version=1.0.31 platform=linux arch=x64
  • install prebuilt binary  name=drivelist version=8.0.10 platform=linux arch=x64
  • build native dependency from sources  name=drivelist
                                          version=8.0.10
                                          platform=linux
                                          arch=x64
                                          reason=prebuild-install failed with error (run with env DEBUG=electron-builder to get more information)
                                          error=prebuild-install info begin Prebuild-install version 5.3.3
    prebuild-install WARN install prebuilt binaries enforced with --force!
    prebuild-install WARN install prebuilt binaries may be out of date!
    prebuild-install info looking for cached prebuild @ /home/unm4sk/.npm/_prebuilds/49bf21-drivelist-v8.0.10-electron-v76-linux-x64.tar.gz
    prebuild-install info found cached prebuild 
    prebuild-install info unpacking @ /home/unm4sk/.npm/_prebuilds/49bf21-drivelist-v8.0.10-electron-v76-linux-x64.tar.gz
    prebuild-install WARN install incorrect header check
    
  • install prebuilt binary  name=mountutils version=1.3.19 platform=linux arch=x64
  • build native dependency from sources  name=ext2fs
                                          version=1.0.31
                                          platform=linux
                                          arch=x64
                                          reason=prebuild-install failed with error (run with env DEBUG=electron-builder to get more information)
                                          error=prebuild-install info begin Prebuild-install version 5.3.3
    prebuild-install WARN install prebuilt binaries enforced with --force!
    prebuild-install WARN install prebuilt binaries may be out of date!
    prebuild-install info looking for cached prebuild @ /home/unm4sk/.npm/_prebuilds/dd792d-ext2fs-v1.0.31-electron-v76-linux-x64.tar.gz
    prebuild-install http request GET https://github.com/balena-io/node-ext2fs/releases/download/v1.0.31/ext2fs-v1.0.31-electron-v76-linux-x64.tar.gz
    prebuild-install http 404 https://github.com/balena-io/node-ext2fs/releases/download/v1.0.31/ext2fs-v1.0.31-electron-v76-linux-x64.tar.gz
    prebuild-install WARN install No prebuilt binaries found (target=8.2.4 runtime=electron arch=x64 libc= platform=linux)
    
  • build native dependency from sources  name=mountutils
                                          version=1.3.19
                                          platform=linux
                                          arch=x64
                                          reason=prebuild-install failed with error (run with env DEBUG=electron-builder to get more information)
                                          error=prebuild-install info begin Prebuild-install version 5.3.3
    prebuild-install WARN install prebuilt binaries enforced with --force!
    prebuild-install WARN install prebuilt binaries may be out of date!
    prebuild-install info looking for cached prebuild @ /home/unm4sk/.npm/_prebuilds/a92ee8-mountutils-v1.3.19-electron-v76-linux-x64.tar.gz
    prebuild-install http request GET https://github.com/resin-io-modules/mountutils/releases/download/v1.3.19/mountutils-v1.3.19-electron-v76-linux-x64.tar.gz
    prebuild-install http 404 https://github.com/resin-io-modules/mountutils/releases/download/v1.3.19/mountutils-v1.3.19-electron-v76-linux-x64.tar.gz
    prebuild-install WARN install No prebuilt binaries found (target=8.2.4 runtime=electron arch=x64 libc= platform=linux)

This results in missing dependencies on project.
Compiling of etcher itself works fine, but inside another app using etcher-sdk fails with installation.

How can I fix this?

Backfill comments from Etcher master

There are a bunch of comments around why things are done in a specific way that have been omitted from the Etcher SDK so far. We should "backport" them

npm install failing with v8.4.0

npm install fails on with v8.4.0 (b5c8e98). Fails both with node v16.18 and v18.15. Definitely looks related to the unbzip2 update.

kbee@system76:~/dev/etcher-sdk/tmp-repo$ npm install
npm ERR! code 2
npm ERR! git dep preparation failed
npm ERR! command /home/kbee/.nvm/versions/node/v18.15.0/bin/node /home/kbee/.nvm/versions/node/v18.15.0/lib/node_modules/npm/bin/npm-cli.js install --force --cache=/home/kbee/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit --include=dev --include=peer --include=optional --no-package-lock-only --no-dry-run
npm ERR! > [email protected] prepare
npm ERR! > browserify -s unbzip2Stream index.js | uglifyjs >> dist/unbzip2-stream.min.js
npm ERR! npm WARN using --force Recommended protections disabled.
npm ERR! npm WARN deprecated [email protected]: Use the built-in String.padStart function instead
npm ERR! npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-url#deprecated
npm ERR! npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm ERR! npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm ERR! npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm ERR! npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-resolve#deprecated
npm ERR! npm WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm ERR! npm WARN deprecated [email protected]: Deprecated due to CVE-2021-21366 resolved in 0.5.0
npm ERR! npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm ERR! npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm ERR! npm WARN deprecated [email protected]: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm ERR! sh: 1: cannot create dist/unbzip2-stream.min.js: Directory nonexistent
npm ERR! npm ERR! code 2
npm ERR! npm ERR! path /home/kbee/.npm/_cacache/tmp/git-cloneXUt5ok
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command sh -c browserify -s unbzip2Stream index.js | uglifyjs >> dist/unbzip2-stream.min.js
npm ERR! 
npm ERR! npm ERR! A complete log of this run can be found in:
npm ERR! npm ERR!     /home/kbee/.npm/_logs/2023-03-09T12_43_46_526Z-debug-0.log

Autogenerated docs link issues

When regenerating the auto-generated docs, I see a lot of changes for the SDK, and some are valid, some are spurious but still an issue.

  • resin referred currently: example, https://github.com/resin-io-modules/etcher-sdk/blob/... When I regenerated it I got balena-io-modules, so maybe the git remote by which the project is checked out is relevant? (I have it checked out by balena-io-modules/etcher-sdk. Here the regeneration actually fixes stuff
  • local file name referred, example Defined in /home/alexis/dev/resin.io/etcher-sdk-2/node_modules/@types/node/index.d.ts:3800, Here on regeneration it will be still wrong, just differently wrong

Ensure that padded writes don't trash previous data on disk

Currently when writing chunks that are non-divisible by the block size, the chunk will be zero-padded to a multiple of the block size – this could potentially wipe data unintentionally when writing smaller parts on disk individually.

While the SDK currently does not facilitate doing this, it should still be implemented properly, by reading the block in question, copy the to-be-written data over and write it back, especially for future use.

Missing definitions [v7.0.0]?

After trying to update to v7, I am getting the following error:

LINK : fatal error LNK1104: cannot open file 'C:\Users\Me\AppData\Roaming\npm-cache_cacache\tmp\git-clone-a3b4f5f6\deps\doc\liblzma.def'

Am I missing something?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update dependency @balena/lint to v6
  • Update dependency @types/file-type to v10
  • Update dependency @types/sinon to v10
  • Update dependency aws4-axios to v3
  • Update dependency axios to v1
  • Update dependency check-disk-space to v3
  • Update dependency debug to v4 (debug, @types/debug)
  • Update dependency file-type to v18
  • Update dependency mocha to v10 (mocha, @types/mocha)
  • Update dependency rimraf to v5
  • Update dependency sinon to v15
  • Update dependency ts-node to v10
  • Update dependency typedoc-plugin-markdown to v3
  • Update dependency typescript to v5
  • Update dependency xxhash-addon to v2
  • Update dependency yargs to v17 (yargs, @types/yargs)
  • 🔐 Create all rate-limited PRs at once 🔐

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/flowzone.yml
npm
package.json
  • @balena/node-beaglebone-usbboot ^3.0.0
  • @balena/udif ^1.1.2
  • @ronomon/direct-io ^3.0.1
  • aws4-axios ^2.4.9
  • axios ^0.27.0
  • balena-image-fs ^7.2.0
  • blockmap ^4.0.3
  • check-disk-space ^2.1.0
  • cyclic-32 ^1.1.0
  • debug ^3.1.0
  • drivelist ^11.1.0
  • file-disk ^8.0.1
  • file-type ^16.5.4
  • gzip-stream ^2.0.0
  • lzma-native ^8.0.6
  • mountutils ^1.3.20
  • node-raspberrypi-usbboot 1.0.6
  • outdent ^0.8.0
  • partitioninfo ^6.0.2
  • rwmutex ^1.0.0
  • tslib ^2.0.0
  • unbzip2-stream 4a54f56a25b58950f9e4277c56db2912d62242e7
  • unzip-stream ^0.3.0
  • xxhash-addon ^1.4.0
  • yauzl ^2.9.2
  • zip-part-stream ^2.0.0
  • @balena/lint ^5.4.0
  • @types/bluebird ^3.5.23
  • @types/chai ^4.1.4
  • @types/cli-spinner ^0.2.0
  • @types/crc ^3.4.0
  • @types/debug 0.0.31
  • @types/file-type ^5.2.1
  • @types/lodash ^4.14.108
  • @types/mocha ^5.2.4
  • @types/node ^18.11.18
  • @types/progress ^2.0.1
  • @types/sinon ^5.0.1
  • @types/yargs ^11.0.0
  • @types/yauzl ^2.9.0
  • chai ^4.1.2
  • cli-spinner ^0.2.8
  • mocha ^8.0.1
  • progress ^2.0.0
  • rimraf ^2.6.2
  • sinon ^6.1.3
  • ts-node ^9.0.0
  • typedoc ^0.17.8
  • typedoc-plugin-markdown 2.4.2
  • typescript ^4.6.3
  • yargs ^16.2.0
  • winusb-driver-generator ^2.0.0
  • node >=16
nvm
.nvmrc
  • node 18

Windows removable device path

Are the scanner.exe and file-to-file.exe examples meant to be usable on windows? Scanner seems to report removable device information, but all drives are missing a devicePath element in the output. There's a device and raw element both of which are something like '\\.\PhysicalDevice2' or similar, but if file-to-file.exe image.iso \\.\PhysicalDevice2 is used a new file is created on c:\ instead of the iso being written to the removable media.

It seems that it should be possible to use some device path such as those listed here: https://www.silabs.com/community/interface/knowledge-base.entry.html/2013/11/21/windows_usb_devicep-aGxD to refer to the usb removable media, but that also seems to fail (and would require some way of looking up the device vid, pid, serial number, and guid which aren't in the scanner output either). Is it possible to get scanner to output a devicePath that can be used to write to with file-to-file example?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update dependency file-type to v19
  • Update dependency yauzl to v3
  • Lock file maintenance
  • 🔐 Create all rate-limited PRs at once 🔐

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/flowzone.yml
npm
package.json
  • @balena/node-beaglebone-usbboot ^3.0.0
  • @balena/udif ^1.1.2
  • @ronomon/direct-io ^3.0.1
  • aws4-axios ^3.3.0
  • axios ^1.6.0
  • balena-image-fs ^7.2.0
  • blockmap ^4.0.3
  • check-disk-space ^3.4.0
  • cyclic-32 ^1.1.0
  • debug ^4.3.4
  • drivelist ^11.2.0
  • file-disk ^8.0.1
  • file-type ^16.0.0
  • glob ^10.3.10
  • gzip-stream ^2.0.0
  • lzma-native ^8.0.6
  • minimatch ^9.0.3
  • mountutils ^1.3.20
  • node-raspberrypi-usbboot 1.0.7
  • outdent ^0.8.0
  • partitioninfo ^6.0.2
  • rwmutex ^1.0.0
  • tslib ^2.0.0
  • unbzip2-stream 4a54f56a25b58950f9e4277c56db2912d62242e7
  • unzip-stream ^0.3.1
  • xxhash-addon ^2.0.1
  • yauzl ^2.9.2
  • zip-part-stream ^2.0.0
  • @balena/lint ^7.2.1
  • @types/bluebird ^3.5.23
  • @types/chai ^4.1.4
  • @types/cli-spinner ^0.2.0
  • @types/crc ^3.4.0
  • @types/debug 4.1.12
  • @types/file-type ^10.9.1
  • @types/lodash ^4.14.108
  • @types/mocha ^10.0.3
  • @types/node ^20.0.0
  • @types/progress ^2.0.1
  • @types/sinon ^17.0.0
  • @types/yargs ^17.0.29
  • @types/yauzl ^2.9.0
  • chai ^4.1.2
  • cli-spinner ^0.2.8
  • mocha ^10.2.0
  • progress ^2.0.0
  • rimraf ^5.0.5
  • sinon ^17.0.0
  • ts-node ^10.9.1
  • typedoc ^0.25.3
  • typedoc-plugin-markdown ^3.16.0
  • typescript ^5.2.2
  • yargs ^17.7.2
  • winusb-driver-generator ^2.0.0
  • node >=18
nvm
.nvmrc
  • node 18

Stream reads before open

Through the lack of emission of an open event (or another mechanism), through which a stream's _read() could hook to (or check), file system reads can occur before a file descriptor is obtained, causing an EBADF error.

Connects to: #9

Should support Node 14

In order for the balena CLI to support Node 14, etcher-sdk needs to support it too. I understand Node 14 support is blocked by the following ext2fs issue: balena-io-modules/node-ext2fs#76

I am creating this issue for greater visibility and understanding of the problem.

Tests failing with "unmount failed, invalid drive"

Test output
$ npm test

> [email protected] test /Users/Jonas/Work/etcher-sdk
> mocha -r ts-node/register tests/**/*.spec.ts



  block-write-stream
    win32
      ✓ should write the correct bytes (318ms)
      ✓ should write the correct bytes sparse (884ms)
    linux
      1) should write the correct bytes
      2) should write the correct bytes sparse

  bzip2 support
    ✓ bzip2 level 9 File (1149ms)
    3) bzip2 level 9 BlockDevice
    ✓ bzip2 level 1 File (946ms)
    4) bzip2 level 1 BlockDevice

  directory
    ✓ should be rejected with an error

  dmg support
    ✓ raw File (218ms)
    5) raw BlockDevice
    ✓ adc File (208ms)
    6) adc BlockDevice
    ✓ zlib File (194ms)
    7) zlib BlockDevice
    ✓ bz2 File (238ms)
    8) bz2 BlockDevice
    ✓ invalid dmg file

  Scanner
    detected devices should be a Set
      ✓ should emit an empty Set
    given only system available drives
      ✓ should emit an empty Set
    given linux
      given available drives
        ✓ should emit the non removable drives
    given windows
      given available drives
        ✓ should emit the non removable drives
      given a drive with a single drive letters
        ✓ should use the drive letter as the name
      given a drive with multiple drive letters
        ✓ should join all the mountpoints in `name`
    given an error when listing the drives
      ✓ should emit the error

  gzip support
    ✓ gzip support File (919ms)
    9) gzip support BlockDevice

  img
    ✓ mbr File (832ms)
    10) mbr BlockDevice
    11) gpt

  SourceDestination.imageExtensions
    ✓ should be an array
    ✓ should not be empty
    ✓ should contain only strings
    ✓ should not contain empty strings
    ✓ should not contain a leading period in any file type extension

  iso support
    ✓ iso File (811ms)
    12) iso BlockDevice

  metadata zip
    ✓ given an archive with an invalid `manifest.json` (116ms)
    ✓ given an archive with a `manifest.json` File (1079ms)
    13) given an archive with a `manifest.json` BlockDevice
    ✓ given an archive with a `logo.svg` File (874ms)
    14) given an archive with a `logo.svg` BlockDevice
    ✓ given an archive with a bmap file File (1774ms)
    15) given an archive with a bmap file BlockDevice
    ✓ given an archive with instructions File (953ms)
    16) given an archive with instructions BlockDevice

  utils
    streamToBuffer
      given a stream that emits data
        ✓ should yield the stream data
      given a stream that throws an error
        ✓ should be rejected with the error

  xz support
    ✓ xz support File (898ms)
    17) xz support BlockDevice

  zip support
    ✓ given an empty zip directory
    ✓ given a zip directory containing only misc files
    ✓ given a zip with an unsupported compression method
    ✓ given a zip directory containing only an image File (896ms)
    18) given a zip directory containing only an image BlockDevice
    ✓ given a zip directory containing an image and other misc files File (858ms)
    19) given a zip directory containing an image and other misc files BlockDevice
    compression method
      ✓ deflate File (874ms)
      20) deflate BlockDevice


  39 passing (49s)
  20 failing

  1) block-write-stream
       linux
         should write the correct bytes:
     Error: Unmount failed, invalid drive
      at Error (native)

  2) block-write-stream
       linux
         should write the correct bytes sparse:
     Error: Unmount failed, invalid drive
      at Error (native)

  3) bzip2 support
       bzip2 level 9 BlockDevice:
     Error: Unmount failed, invalid drive
      at Error (native)

  4) bzip2 support
       bzip2 level 1 BlockDevice:
     Error: Unmount failed, invalid drive
      at Error (native)

  5) dmg support
       raw BlockDevice:
     Error: Unmount failed, invalid drive
      at Error (native)

  6) dmg support
       adc BlockDevice:
     Error: Unmount failed, invalid drive
      at Error (native)

  7) dmg support
       zlib BlockDevice:
     Error: Unmount failed, invalid drive
      at Error (native)

  8) dmg support
       bz2 BlockDevice:
     Error: Unmount failed, invalid drive
      at Error (native)

  9) gzip support
       gzip support BlockDevice:
     Error: Unmount failed, invalid drive
      at Error (native)

  10) img
       mbr BlockDevice:
     Error: Unmount failed, invalid drive
      at Error (native)

  11) img
       gpt:
     Error: Timeout of 20000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/Users/Jonas/Work/etcher-sdk/tests/img.spec.ts)


  12) iso support
       iso BlockDevice:
     Error: Unmount failed, invalid drive
      at Error (native)

  13) metadata zip
       given an archive with a `manifest.json` BlockDevice:
     Error: Unmount failed, invalid drive
      at Error (native)

  14) metadata zip
       given an archive with a `logo.svg` BlockDevice:
     Error: Unmount failed, invalid drive
      at Error (native)

  15) metadata zip
       given an archive with a bmap file BlockDevice:
     Error: Unmount failed, invalid drive
      at Error (native)

  16) metadata zip
       given an archive with instructions BlockDevice:
     Error: Unmount failed, invalid drive
      at Error (native)

  17) xz support
       xz support BlockDevice:
     Error: Unmount failed, invalid drive
      at Error (native)

  18) zip support
       given a zip directory containing only an image BlockDevice:
     Error: Unmount failed, invalid drive
      at Error (native)

  19) zip support
       given a zip directory containing an image and other misc files BlockDevice:
     Error: Unmount failed, invalid drive
      at Error (native)

  20) zip support
       compression method
         deflate BlockDevice:
     Error: Unmount failed, invalid drive
      at Error (native)



npm ERR! Test failed.  See above for more details.

Don't propagate unmount error on windows to UI if verification succeeded.

A lot of users are getting errors that the unmount operation failed:

balena-io/etcher#3542
balena-io/etcher#3730
balena-io/etcher#1370

...etc.

Even though the verification makes it to 100%.

We can see that even if a user has a task manager open, the device can be marked as busy:

balena-io/etcher#1316

Even though nothing has changed, the task manager just has the device open, so it is marked as "busy".

If we make it to 100% verification, the flashing has succeeded, and so there is no need to propagate a failure error to the user, because the user thinks that something has gone wrong with the flashing process.

We should only show the error if the verification has failed.

Ultimately we should try to open the device exclusively so that no other process can have the device open to cause this error, but this is a more difficult problem.

Reporting a vulnerability

Hello!

I hope you are doing well!

We are a security research team. Our tool automatically detected a vulnerability in this repository. We want to disclose it responsibly. GitHub has a feature called Private vulnerability reporting, which enables security research to privately disclose a vulnerability. Unfortunately, it is not enabled for this repository.

Can you enable it, so that we can report it?

Thanks in advance!

PS: you can read about how to enable private vulnerability reporting here: https://docs.github.com/en/code-security/security-advisories/repository-security-advisories/configuring-private-vulnerability-reporting-for-a-repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.