Skip to content

Commit

Permalink
Initial readme
Browse files Browse the repository at this point in the history
  • Loading branch information
abdolence committed Aug 4, 2024
1 parent 0b65b2e commit e6610d9
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ jobs:
run: cargo test
if: github.ref != 'refs/heads/master'
- name: 'Run all test'
run: cargo test --features "ci"
run: cargo test --features "ci-gcp"
if: github.ref == 'refs/heads/master'
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ mime = "0.3"
mime_guess = "2"
zip = "2"
globset = "0.4"
tempdir = "0.3"
tempfile = "3"
csv-async = { version = "1", default-features = false, features = ["tokio", "tokio-stream"] }
aws-config = { version = "1", features = ["behavior-version-latest"] }
aws-sdk-s3 = { version = "1" }
Expand Down
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[![Cargo](https://img.shields.io/crates/v/redacter.svg)](https://crates.io/crates/redacter)
![tests and formatting](https://github.com/abdolence/redacter-rs/workflows/tests%20&%20formatting/badge.svg)
![security audit](https://github.com/abdolence/redacter-rs/workflows/security%20audit/badge.svg)

# Redacter

Copy & Redact cli tool to securely copy and redact files across various sources and destinations,
utilizing Data Loss Prevention (DLP) capabilities.

## Features

* **Copy & Redact:** copy files while applying DLP redaction to protect sensitive information.
* **Multiple Sources & Destinations:** interact with:
* Local filesystem
* Google Cloud Storage (GCS)
* Amazon Simple Storage Service (S3)
* Zip files
* **GCP DLP Integration:** Leverage the power of GCP's DLP API for accurate and customizable redaction.
* **CLI:** Easy-to-use command-line interface for streamlined workflows.
* Built with Rust to ensure speed, safety, and reliability.

## Installation

**Cargo:**

```sh
cargo install redacter
```

## Command line options

TBD

## Google authentication

Looks for credentials in the following places, preferring the first location found:

- A JSON file whose path is specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable.
- A JSON file in a location known to the gcloud command-line tool using `gcloud auth application-default login`.
- On Google Compute Engine, it fetches credentials from the metadata server.

## Licence

Apache Software License (ASL)

## Author

Abdulla Abdurakhmanov
5 changes: 3 additions & 2 deletions src/filesystems/aws_s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ impl<'a> AwsS3FileSystem<'a> {
name.trim_start_matches(&self.object_name).into();
let media_type = mime_guess::from_path(&name).first();
FileSystemRef {
relative_path: relative_path,
media_type: media_type,
relative_path,
media_type,
file_size: item.size.map(|v| v as u64),
}
})
Expand Down Expand Up @@ -246,6 +246,7 @@ impl<'a> FileSystemConnection<'a> for AwsS3FileSystem<'a> {
}
}

#[allow(unused_imports)]
mod tests {
use super::*;
use crate::reporter::AppReporter;
Expand Down
1 change: 1 addition & 0 deletions src/filesystems/file_matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ impl FileMatcher {
}
}

#[allow(unused_imports)]
mod tests {
use super::*;
use crate::filesystems::*;
Expand Down
1 change: 1 addition & 0 deletions src/filesystems/gcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ impl<'a> FileSystemConnection<'a> for GoogleCloudStorageFileSystem<'a> {
}
}

#[allow(unused_imports)]
mod tests {
use super::*;
use crate::reporter::AppReporter;
Expand Down
7 changes: 4 additions & 3 deletions src/filesystems/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ impl<'a> FileSystemConnection<'a> for LocalFileSystem<'a> {
}
}

#[allow(unused_imports)]
mod tests {
use super::*;
use crate::filesystems::DetectFileSystem;
Expand All @@ -178,7 +179,7 @@ mod tests {
async fn download_test() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let term = Term::stdout();
let reporter: AppReporter = AppReporter::from(&term);
let temp_dir = tempdir::TempDir::new("local_file_system_tests_download")?;
let temp_dir = tempfile::TempDir::with_prefix("local_file_system_tests_download")?;
let temp_dir_path = temp_dir.path();

let fs = DetectFileSystem::open(
Expand Down Expand Up @@ -217,7 +218,7 @@ mod tests {
async fn upload_test() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let term = Term::stdout();
let reporter: AppReporter = AppReporter::from(&term);
let temp_dir = tempdir::TempDir::new("local_file_system_tests_upload")?;
let temp_dir = tempfile::TempDir::with_prefix("local_file_system_tests_upload")?;
let temp_dir_path = temp_dir.path();

let fs = DetectFileSystem::open(
Expand Down Expand Up @@ -252,7 +253,7 @@ mod tests {
async fn list_test() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let term = Term::stdout();
let reporter: AppReporter = AppReporter::from(&term);
let temp_dir = tempdir::TempDir::new("local_file_system_tests_list")?;
let temp_dir = tempfile::TempDir::with_prefix("local_file_system_tests_list")?;
let temp_dir_path = temp_dir.path();

let fs = DetectFileSystem::open(
Expand Down
13 changes: 7 additions & 6 deletions src/filesystems/zip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use gcloud_sdk::prost::bytes::Bytes;
use rvstruct::ValueStruct;
use std::io::Write;
use std::path::{Path, PathBuf};
use tempdir::TempDir;
use tempfile::TempDir;
use zip::*;

pub struct ZipFileSystem<'a> {
Expand Down Expand Up @@ -51,7 +51,7 @@ impl<'a> ZipFileSystem<'a> {
if self.mode.is_none() {
let file = std::fs::File::open(&self.zip_file_path)?;
let mut archive = ZipArchive::new(file)?;
let temp_dir = TempDir::new("redacter")?;
let temp_dir = tempfile::TempDir::with_prefix("redacter")?;
archive.extract(temp_dir.path())?;
let temp_dir_str = temp_dir.path().to_string_lossy();
self.reporter
Expand Down Expand Up @@ -177,17 +177,18 @@ impl<'a> FileSystemConnection<'a> for ZipFileSystem<'a> {
}
}

#[allow(unused_imports)]
mod tests {
use super::*;
use gcloud_sdk::prost::bytes;
use std::io::Read;
use tempdir::TempDir;
use tempfile::TempDir;

#[tokio::test]
async fn download_test() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let term = console::Term::stdout();
let reporter: AppReporter = AppReporter::from(&term);
let temp_dir = TempDir::new("zip_file_system_tests_download")?;
let temp_dir = TempDir::with_prefix("zip_file_system_tests_download")?;
let temp_dir_path = temp_dir.path();
let zip_file_path = temp_dir_path.join("test.zip");
let mut zip = ZipWriter::new(std::fs::File::create(&zip_file_path)?);
Expand Down Expand Up @@ -225,7 +226,7 @@ mod tests {
async fn upload_test() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let term = console::Term::stdout();
let reporter: AppReporter = AppReporter::from(&term);
let temp_dir = TempDir::new("zip_file_system_tests_upload")?;
let temp_dir = TempDir::with_prefix("zip_file_system_tests_upload")?;
let temp_dir_path = temp_dir.path();
let zip_file_path = temp_dir_path.join("test.zip");

Expand Down Expand Up @@ -262,7 +263,7 @@ mod tests {
async fn list_files_test() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let term = console::Term::stdout();
let reporter: AppReporter = AppReporter::from(&term);
let temp_dir = TempDir::new("zip_file_system_tests_list_files")?;
let temp_dir = TempDir::with_prefix("zip_file_system_tests_list_files")?;
let temp_dir_path = temp_dir.path();
let zip_file_path = temp_dir_path.join("test.zip");
let mut zip = ZipWriter::new(std::fs::File::create(&zip_file_path)?);
Expand Down
1 change: 1 addition & 0 deletions src/redacters/gcp_dlp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ impl TryInto<gcloud_sdk::google::privacy::dlp::v2::ByteContentItem> for Redacter
}
}

#[allow(unused_imports)]
mod tests {
use super::*;
use crate::redacters::RedacterProviderOptions;
Expand Down

0 comments on commit e6610d9

Please sign in to comment.