Adding to .zip archive removes file system access rules
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 45/100
Piste de recherche
Commencez dans src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs, au niveau du code de finalisation autour des lignes 3132-3143 et de la gestion de la sortie temporaire et finale autour des lignes 4663-4713. Reproduisez le problème avec le test fourni AddEntryRevertingFilePermissions, puis ajoutez une couverture de régression montrant qu’une règle d’accès sur l’archive reste présente après CommitUpdate().
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
When adding to a .zip archive on disk, the update does not happen in place. Instead, a temporary .zip file with the updated contents is created in a temporary directory first, which replaces the original archive after a successful write. As a result, any file system access rules set on the .zip archive that is updated are lost.
Steps to reproduce
- Run the snippet below in a debugger
[Test]
[Category("Zip")]
[Category("CreatesTempFile")]
public void AddEntryRevertingFilePermissions()
{
const string TestValue = "0001000";
string tempFile = "c:/temp/";
Assert.IsNotNull(tempFile, "No permission to execute this test?");
tempFile = Path.Combine(tempFile, "SharpZipTest.Zip");
// create empty zip file
using (ZipFile f = ZipFile.Create(tempFile))
{
f.BeginUpdate();
f.CommitUpdate();
}
Console.WriteLine("break here and manually amend permissions for c:/temp/SharpZipTest.Zip by adding a rule");
using (ZipFile f = new ZipFile(tempFile))
{
var m = new StringMemoryDataSource(TestValue);
f.BeginUpdate();
f.Add(m, "a.dat");
f.CommitUpdate();
}
Console.WriteLine("permissions for c:/temp/SharpZipTest.Zip are reverted");
}
- Break in the middle and amend permissions to the file by adding an access rule.
- Run to completion and verify that the file permission has reverted.
Expected behavior
File permissions should be retained
Actual behavior
File permissions inherited from temporary directory (e.g. C:\Users\username\AppData\Local\Temp\) are set
Version of SharpZipLib
Obtained from (only keep the relevant lines)
- Compiled from source, commit: https://github.com/icsharpcode/SharpZipLib/commit/cd5310f5b7eed595110b76a2f7ae5ee013cc50f1
Further detail
The update is finalised: (directUpdate is false)
https://github.com/icsharpcode/SharpZipLib/blob/cd5310f5b7eed595110b76a2f7ae5ee013cc50f1/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs#L3132-L3143
The temporary output (pointing to a temporary directory ) is created at https://github.com/icsharpcode/SharpZipLib/blob/cd5310f5b7eed595110b76a2f7ae5ee013cc50f1/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs#L4663-L4669
The final output is created at
https://github.com/icsharpcode/SharpZipLib/blob/cd5310f5b7eed595110b76a2f7ae5ee013cc50f1/src/ICSharpCode.SharpZipLib/Zip/ZipFile.cs#L4676-L4713
- Langage dominant
- C#
- Étoiles
- 3.9k
- Forks
- 1k
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de icsharpcode/SharpZipLib
-
*no response* bug
Difficulté 1/5 Moins d'une heure Accessibilité débutants 78/100
icsharpcode/SharpZipLib#905 · 1 commentaire ·
-
bug bzip2
Difficulté 4/5 3-5 jours Accessibilité débutants 45/100
icsharpcode/SharpZipLib#904 ·
-
SetLevel in ZipFileOuverteenhancement zip
Difficulté 2/5 1-2 jours Accessibilité débutants 55/100
icsharpcode/SharpZipLib#903 ·
-
*no response* bug
Difficulté 4/5 3-5 jours Accessibilité débutants 32/100
icsharpcode/SharpZipLib#901 · 1 commentaire ·
-
*no response* bug
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
icsharpcode/SharpZipLib#894 · 1 commentaire ·
Toutes les issues de icsharpcode/SharpZipLib
Issues similaires
-
area-System.Numerics.Tensors untriaged
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
dotnet/runtime#134691 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
unoplatform/uno.templates#2277 ·
Les mainteneurs répondent en général sous 5 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
microsoft/fluentui-blazor#5344 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
difficulty/starter 🚀 good first issue kind/bug platform/all project/core-tools 🛠️ triage/untriaged
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
unoplatform/uno#24757 ·
Les mainteneurs répondent en général sous 1 jour
-
ci-failure-cause test-failure
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour