GithubHelp home page GithubHelp logo

cube-soft / cube.filesystem.sevenzip Goto Github PK

View Code? Open in Web Editor NEW
45.0 7.0 8.0 11.7 MB

CubeICE and 7-Zip wrapper library for .NET

Home Page: https://www.cube-soft.jp/cubeice/

License: Other

C# 85.71% C++ 12.85% Ruby 0.46% C 0.97%
cube 7-zip 7z sevenzip zip csharp dotnet net45 net35

cube.filesystem.sevenzip's Introduction

Cube.FileSystem.SevenZip

Package AppVeyor Codecov

Cube.FileSystem.SevenZip is a wrapper library of the 7-Zip via COM interface. The project also has an application for compressing or extracting archives, which name is CubeICE. Libraries and applications are available for .NET Framework 3.5, 4.5 or later. Note that some projects are licensed under the GNU LGPLv3 and the others under the Apache 2.0. See License.md for more information.

Usage

You can install the library through the NuGet package. Add dependencies in your project file or select it from the NuGet packages UI on Visual Studio.

Examples for archiving files

A simple example for archiving files is as follows. Note that the statement "using Cube.FileSystem.SevenZip;" has been omitted in all samples.

// Set only what you need.
var files   = new[] { ".DS_Store", "Thumbs.db", "__MACOSX", "desktop.ini" };
var options = new CompressionOption
{
    CompressionLevel  = CompressionLevel.Ultra,
    CompressionMethod = CompressionMethod.Lzma,
    EncryptionMethod  = EncryptionMethod.Aes256,
    Password          = "password",
    Filter            = Filter.From(files),
    CodePage          = CodePage.Utf8,
};

using (var writer = new ArchiveWriter(Format.Zip, options))
{
    writer.Add(@"path\to\file");
    writer.Add(@"path\to\directory_including_files");
    
    var progress = new Progress<Report>(e => DoSomething(e));
    writer.Save(@"path\to\save.zip", progress);
}

You create an ArchiveWriter object with an archiving format (e.g. Zip, SevenZip, ...), add files and/or directories you want to archive, set some additional options, and finally call the Save method. When you create Tar based archives, you can use a TarOption object for selecting a compression method.

var options = new CompressionOption
{
    CompressionLevel  = CompressionLevel.Ultra,
    CompressionMethod = CompressionMethod.BZip2, // GZip, BZip2, XZ or Copy
};

using (var writer = new ArchiveWriter(Format.Tar, options))
{
    writer.Add(@"path\to\file");
    writer.Add(@"path\to\directory_including_files");
    writer.Save(@"path\to\save.tar.gz");
}

Examples for extracting archives

If you want to extract all files from the archive, you create an ArchiveReader object and call the Extract method. The 2nd argument of the constructor, that means the password of the archive, can be set string or Cube.Query<string> object. The latter is mainly used for implementing the interactive mode.

// Set password directly or using Query<string>
var password = new Cube.Query<string>(e =>
{
    e.Result = "password";
    e.Cancel = false;
});

// Supports only the Filter property
var files   = new[] { ".DS_Store", "Thumbs.db", "__MACOSX", "desktop.ini" };
var options = new ArchiveOption { Filter = Filter.From(files) };

using (var reader = new ArchiveReader(@"path\to\archive", password, options))
{
    var progress = new Progress<Report>(e => DoSomething(e));
    reader.Save(@"path\to\directory", progress);
}

Note that ArchiveWriter and ArchiveReader classes need to execute in the same thread from constructing to destroying. Use Task.Run() in the whole transaction if you need to archive or extract files asynchronously.

Dependencies

Contributing

  1. Fork Cube.FileSystem.SevenZip repository.
  2. Create a feature branch from the master (e.g. git checkout -b my-new-feature origin/master). Note that the master branch may refer some pre-released NuGet packages. Try the rake clean command when build errors occur.
  3. Commit your changes.
  4. Rebase your local changes against the master branch.
  5. Run the dotnet test command or the Visual Studio (NUnit 3 test adapter) and confirm that it passes.
  6. Create new Pull Request.

License

Copyright © 2010 CubeSoft, Inc. See License.md for more information.

cube.filesystem.sevenzip's People

Contributors

clown avatar mend-bolt-for-github[bot] 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cube.filesystem.sevenzip's Issues

CVE-2019-0820 (High) detected in system.text.regularexpressions.4.1.0.nupkg

CVE-2019-0820 - High Severity Vulnerability

Vulnerable Library - system.text.regularexpressions.4.1.0.nupkg

Provides the System.Text.RegularExpressions.Regex class, an implementation of a regular expression e...

Library home page: https://api.nuget.org/packages/system.text.regularexpressions.4.1.0.nupkg

Path to dependency file: Cube.FileSystem.SevenZip/Tests/Core/Cube.FileSystem.SevenZip.Tests.csproj

Path to vulnerable library: /usr/share/dotnet/sdk/NuGetFallbackFolder/system.text.regularexpressions/4.1.0/system.text.regularexpressions.4.1.0.nupkg

Dependency Hierarchy:

  • microsoft.testplatform.testhost.16.11.0.nupkg (Root Library)
    • newtonsoft.json.9.0.1.nupkg
      • system.text.regularexpressions.4.1.0.nupkg (Vulnerable Library)

Found in HEAD commit: 6a27184717c328b299d9849974b22253fe1c3a36

Vulnerability Details

A denial of service vulnerability exists when .NET Framework and .NET Core improperly process RegEx strings, aka '.NET Framework and .NET Core Denial of Service Vulnerability'. This CVE ID is unique from CVE-2019-0980, CVE-2019-0981.

Publish Date: 2019-05-16

URL: CVE-2019-0820

CVSS 3 Score Details (7.5)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: Low
    • Privileges Required: None
    • User Interaction: None
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: None
    • Integrity Impact: None
    • Availability Impact: High

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: GHSA-cmhx-cq75-c4mj

Release Date: 2020-08-24

Fix Resolution: System.Text.RegularExpressions - 4.3.1


Step up your Open Source Security Game with WhiteSource here

WS-2022-0161 (High) detected in opencover.4.7.1221.nupkg - autoclosed

WS-2022-0161 - High Severity Vulnerability

Vulnerable Library - opencover.4.7.1221.nupkg

An open source code coverage tool (branch and sequence point) for all .NET Frameworks 2 and above. A...

Library home page: https://api.nuget.org/packages/opencover.4.7.1221.nupkg

Path to dependency file: /Tests/Core/Cube.FileSystem.SevenZip.Tests.csproj

Path to vulnerable library: /tmp/ws-scm/packages/opencover/4.7.1221/opencover.4.7.1221.nupkg

Dependency Hierarchy:

  • cube.tests.7.0.0.nupkg (Root Library)
    • opencover.4.7.1221.nupkg (Vulnerable Library)

Found in HEAD commit: d95bec714482e12d1c8f1b48fdbaf7cd71b2e0d4

Found in base branch: master

Vulnerability Details

Improper Handling of Exceptional Conditions in Newtonsoft.Json.
Newtonsoft.Json prior to version 13.0.1 is vulnerable to Insecure Defaults due to improper handling of StackOverFlow exception (SOE) whenever nested expressions are being processed. Exploiting this vulnerability results in Denial Of Service (DoS), and it is exploitable when an attacker sends 5 requests that cause SOE in time frame of 5 minutes. This vulnerability affects Internet Information Services (IIS) Applications.

Publish Date: 2022-06-22

URL: WS-2022-0161

CVSS 3 Score Details (7.5)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: Low
    • Privileges Required: None
    • User Interaction: None
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: None
    • Integrity Impact: None
    • Availability Impact: High

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Release Date: 2022-06-22

Fix Resolution: Newtonsoft.Json - 13.0.1;Microsoft.Extensions.ApiDescription.Server - 6.0.0


Step up your Open Source Security Game with Mend here

missing test mode interface, please add option for testing archives

find only extract
public void Extract(string directory, IProgress progress)
{
using (var cb = Create(directory, progress))
{
_module.Extract(null, uint.MaxValue, 0, cb);
Terminate(cb.Result, cb.Exception);
}
}

_module.Extract(null, uint.MaxValue, 0, cb);
===>

test != 0 means "test files operation"

test flag always is zero

Changing 0 to 1 throwing exception ;(

Changes APIs for filtering

Changes APIs for filtering as follows (BREAKING CHANGES):

  • Rename the current Filter class to FilterCollectioin.
  • Create a new static class named Filter, and create a Predicate From(IEnumerable) static method.

Please add check for zero filled / zero sized archives

When use zero filled .rar file

  		using(var archive = new ArchiveReader(file.FullName))
  			{
  				foreach(var item in archive.Items)

Getting uncatchable exception in

d:\work\is-keeper\src\Lib\Cube.FileSystem.SevenZip\Details\ArchiveItemController.cs

   private T Get<T>(string src, ItemPropId pid)
    {
        var var = new PropVariant();
        _archive.GetProperty((uint)Index, pid, ref var);

Unhandled exception System.NullReferenceException in ArchiveReader.cs

Hi,

at first, thank you for this wrapper. When testing my app where I used your wrapper, I probably found a bug. There is following code in my app:
using (var extractor = new ArchiveReader(inputpath)) { extractor.Extract(outputpath); }

When I try to call Extract method via extractor object, following exception in Cube.FileSystem.SevenZip.dll is thrown:

Exception thrown: 'System.NullReferenceException' in Cube.FileSystem.SevenZip.dll
_callback was null.

Problematic code is in your ArchiveReader.cs file, line 264. _callback object is null and it is not possible to dispose it:
protected override void Dispose(bool disposing) { _callback.Dispose(); _module.Close(); _core.Dispose(); }

Problematic archive attached.

Google%20Chrome%20Extension.zip

Thank you,
David

CVE-2018-1285 (High) detected in log4net.2.0.8.nupkg

CVE-2018-1285 - High Severity Vulnerability

Vulnerable Library - log4net.2.0.8.nupkg

The Apache log4net library is a tool to help the programmer output log statements to a variety of ou...

Library home page: https://api.nuget.org/packages/log4net.2.0.8.nupkg

Path to dependency file: Cube.FileSystem.SevenZip/Tests/Core/Examples/Sample/Cube.Images.nuspec

Path to vulnerable library: Cube.FileSystem.SevenZip/Tests/Core/Examples/Sample/Cube.Images.nuspec

Dependency Hierarchy:

  • log4net.2.0.8.nupkg (Vulnerable Library)

Found in HEAD commit: 658de7707e33a4ae9a27a89acb865b13c6df5889

Vulnerability Details

Apache log4net versions before 2.0.10 do not disable XML external entities when parsing log4net configuration files. This allows for XXE-based attacks in applications that accept attacker-controlled log4net configuration files.

Publish Date: 2020-05-11

URL: CVE-2018-1285

CVSS 3 Score Details (9.8)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: Low
    • Privileges Required: None
    • User Interaction: None
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: High
    • Integrity Impact: High
    • Availability Impact: High

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: https://github.com/apache/logging-log4net/tree/rel/2.0.10

Release Date: 2020-05-11

Fix Resolution: log4net - 2.0.10


Step up your Open Source Security Game with WhiteSource here

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.