Skip to content

Commit 0cdabbb

Browse files
authored
Standardize code formatting and detect local directory (#3)
* standardize code formatting and detect local directory Signed-off-by: sonichen <[email protected]> * standardize code formatting and detect local directory Signed-off-by: sonichen <[email protected]> --------- Signed-off-by: sonichen <[email protected]>
1 parent 2b21bb3 commit 0cdabbb

26 files changed

+4786
-1
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "cargo" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "daily"

.github/workflows/base.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Based on https://github.com/actions-rs/meta/blob/master/recipes/quickstart.md
2+
#
3+
# History:
4+
# 1. 2023-02-14: Created at 2023-02-14T16:00:00Z by Quanyi Ma <[email protected]>
5+
#
6+
#
7+
#
8+
9+
on: [ push, pull_request ]
10+
11+
name: Base GitHub Action for Check, Test and Lints
12+
13+
jobs:
14+
check:
15+
name: Check
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v2
19+
- uses: actions-rs/toolchain@v1
20+
with:
21+
profile: minimal
22+
toolchain: stable
23+
override: true
24+
- uses: actions-rs/cargo@v1
25+
with:
26+
command: check
27+
28+
test:
29+
name: Test Suite
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v2
33+
- uses: actions-rs/toolchain@v1
34+
with:
35+
profile: minimal
36+
toolchain: stable
37+
override: true
38+
- uses: actions-rs/cargo@v1
39+
with:
40+
command: test
41+
42+
clippy:
43+
name: Clippy
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v2
47+
- uses: actions-rs/toolchain@v1
48+
with:
49+
profile: minimal
50+
toolchain: stable
51+
override: true
52+
- run: rustup component add clippy
53+
- uses: actions-rs/cargo@v1
54+
with:
55+
command: clippy
56+
args: -- -D warnings

CODE-OF-CONDUCT.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# CODE OF CONDUCT
2+
3+
This code of conduct outlines the expected behavior of all members of Open Rust Initiative to ensure a safe, productive, and inclusive environment for everyone.
4+
5+
All members of Open Rust Initiative, including employees, contractors, interns, volunteers, and anyone else represents the company, are expected to behave in a professional, respectful, considerate, and collaborative manner. Harassment, discrimination, or toxic behavior of any kind will not be tolerated.
6+
7+
Open Rust Initiative is committed to providing an environment free of harassment and discrimination for everyone, regardless of gender, gender identity and expression, sexual orientation, disability, physical appearance, body size, race, age, or religion. We do not tolerate harassment of participants in any form. Harassment includes offensive comments related to these characteristics, as well as deliberate intimidation, stalking, following, harassing photography or recording, sustained disruption of talks or other events, inappropriate physical contact, and unwelcome sexual attention.
8+
9+
If you experience or witness unacceptable behavior, see something that makes you feel unsafe, or have concerns about the well-being of a participant, please report it to Eli Ma or Charles Feng immediately. All reports will be handled confidentially.
10+
11+
We value diverse opinions, skills, and experiences. We strive to build an inclusive environment where everyone feels safe and respected. Together, we can achieve great things.
12+
13+
THANK YOU FOR YOUR COOPERATION IN ADVANCING OUR COMMITMENT TO INCLUSION AND RESPECT.
14+
15+
Responsibilities
16+
17+
All members of Open Rust Initiative are expected to:
18+
19+
- Treat all people with respect and consideration, valuing a diversity of views and opinions.
20+
• Communicate openly and thoughtfully.
21+
• Avoid personal attacks directed at other participants.
22+
• Be mindful of your surroundings and your fellow participants. Alert Eli Ma if you notice a dangerous situation or someone in distress.
23+
• Respect personal space and property.
24+
• Refrain from demeaning, discriminatory, or harassing behavior, speech, and imagery.
25+
• Be considerate in your use of space and resources. For example, avoid excessive noise from conversations, laptops, and other electronic devices. Be courteous when taking up shared space such as tables and walkways.
26+
• Follow the instructions of Open Rust Initiative staff and security.
27+
• Avoid using language that reinforces social and cultural structures of domination related to gender, gender identity and expression, sexual orientation, disability, physical appearance, body size, race, age, religion, or other personal characteristics.
28+
29+
Consequences
30+
31+
Failure to comply with this Code of Conduct may result in disciplinary action, including removal from Open Rust Initiative spaces and events and prohibition from future participation.
32+
33+
Contact Information
34+
35+
If you have questions or concerns about this Code of Conduct, contact Eli Ma or Charles Feng.
36+
37+
# Enforcement
38+
39+
Open Rust Initiative prioritizes creating a safe and positive experience for everyone. We do not tolerate harassment or discrimination of any kind.
40+
41+
We expect participants to follow these rules at all Open Rust Initiative venues and events. Open Rust Initiative staff will enforce this Code of Conduct.
42+
43+
If a participant engages in harassing or discriminatory behavior, Open Rust Initiative staff will take reasonable action they deem appropriate, including warning the offender, expulsion from an event, or banning them from future events.
44+
45+
At their discretion, Open Rust Initiative staff may report offenders to local law enforcement. Open Rust Initiative staff may take action against participants for other behaviors that violate this Code of Conduct or negatively impact the safety and inclusion of event participants.

CONTRIBUTING.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# CONTRIBUTING
2+
3+
Thank you for your interest in contributing to this project. There are many ways you can contribute, from writing tutorials or blog posts, improving the documentation, submitting bug reports and feature requests, all the way to developing code which can be incorporated into the project.
4+
5+
As a contributor, you agree to abide by the Code of Conduct enforced in this community.
6+
7+
## How to contribute
8+
9+
Here are some guidelines for contributing to this project:
10+
11+
1. Report issues/bugs: If you find any issues or bugs in the project, please report them by creating an issue on the issue tracker. Describe the issue in detail and also mention the steps to reproduce it. The more details you provide, the easier it will be for me to investigate and fix the issue.
12+
2. Suggest enhancements: If you have an idea to enhance or improve this project, you can suggest it by creating an issue on the issue tracker. Explain your enhancement in detail along with its use cases and benefits. I appreciate well-thought-out enhancement suggestions.
13+
3. Contribute code: If you want to develop and contribute code, follow these steps:
14+
- Fork the repository and clone it locally.
15+
- Create a new branch for your feature/bugfix.
16+
- Make necessary changes and commit them with proper commit messages.
17+
- Push your changes to your fork and create a pull request.
18+
- I will review your changes and merge the PR if found suitable. Please ensure your code is properly formatted and follows the same style as the existing codebase.
19+
1. Write tutorials/blog posts: You can contribute by writing tutorials or blog posts to help users get started with this project. Submit your posts on the issue tracker for review and inclusion. High quality posts that provide value to users are highly appreciated.
20+
2. Improve documentation: If you find any gaps in the documentation or think any part can be improved, you can make changes to files in the documentation folder and submit a PR. Ensure the documentation is up-to-date with the latest changes.
21+
22+
Your contributions are highly appreciated. Feel free to ask any questions if you have any doubts or facing issues while contributing. The more you contribute, the more you will learn and improve your skills.

Cargo.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[package]
2+
name = "sensleak"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
9+
10+
[dependencies]
11+
regex = "1.5.4"
12+
clap = { version = "4.2.4", features = ["derive"] }
13+
toml="0.7.3"
14+
walkdir = "2.3.2"
15+
rayon = "1.5.1"
16+
serde = { version = "1.0", features = ["derive"] }
17+
serde_json = "1.0"
18+
chrono = "0.4"
19+
assert_cmd = "2.0.10"
20+
tempfile = "3.2.0"

LICENSE-MIT

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 - 2023 Open Rust Initiative
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 143 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,143 @@
1-
# sensleak-rs
1+
# sensleak-rs
2+
3+
sensleak-rs is developing a detect tool similar to gitleaks using Rust, which will detecting hardcoded secrets like passwords, api keys, and tokens in git repos.
4+
5+
## Background
6+
7+
Many developers store sensitive information such as keys and certificates in their code, which poses security risks. Therefore, there are commercial services like GitGuardian scanning GitHub and GitLab, as well as open-source components like truffleHog and Gitleaks that support similar functionalities.
8+
9+
### Requirements
10+
11+
Develop a Git repository sensitive data detection tool using the Rust programming language.
12+
13+
1. Develop in Rust for improved security.
14+
2. Command-line tool that outputs a test report.
15+
3. Support running as a service and provide access control through a REST API.
16+
17+
### Environment
18+
19+
- Runs on X86_64 and ARM64 architectures.
20+
- Uses Rust Edition 2021.
21+
22+
## Usage
23+
24+
Here are a few examples of how to use the tool in different scenarios:
25+
26+
- Running the tool in the command-line interface (CLI) to perform sensitive data checks.
27+
28+
**Note: This project is currently under development. The following features describe sensitive information search within a local folder.**
29+
30+
```shell
31+
sensleaks-rs
32+
33+
Usage: sensleak.exe [OPTIONS] --repo <REPO>
34+
35+
Options:
36+
-r, --repo <REPO> Target repository
37+
-c, --config <CONFIG> Config path.. [default: gitleaks.toml]
38+
-o, --report <REPORT> Path to write json leaks file [default: ]
39+
-v, --verbose Show verbose output from scan
40+
-e, --pretty Pretty print json if leaks are present
41+
-h, --help Print help (see more with '--help')
42+
-V, --version Print version
43+
44+
Repository: https://github.com/open-rust-initiative/sensleak-rs
45+
```
46+
47+
Examples: (test the file in src\tests\files\test)
48+
49+
```shell
50+
sensleak -r="tests\files\test" -v -e
51+
```
52+
53+
Output:
54+
55+
```shell
56+
[
57+
OutputItem {
58+
line: "token = sk_test_abcd1234567890efghijklmno",
59+
line_number: 5,
60+
secret: "sk_test_abcd1234567890efghijklmno",
61+
entropy: "",
62+
commit: "",
63+
repo: "",
64+
rule: "Stripe Access Token",
65+
commit_message: "",
66+
author: "",
67+
email: "",
68+
file: "tests\\files\\test\\file2.txt",
69+
date: "",
70+
tags: "",
71+
operation: "",
72+
},
73+
OutputItem {
74+
line: "twilio_api_key = SK12345678901234567890123456789012",
75+
line_number: 6,
76+
secret: "SK12345678901234567890123456789012",
77+
entropy: "",
78+
commit: "",
79+
repo: "",
80+
rule: "Twilio API Key",
81+
commit_message: "",
82+
author: "",
83+
email: "",
84+
file: "tests\\files\\test\\file2.txt",
85+
date: "",
86+
tags: "",
87+
operation: "",
88+
},
89+
....
90+
]
91+
WARN:[2023-05-17 09:45:07]10 leaks detected. XXX commits scanned in 66.6222ms
92+
```
93+
94+
95+
96+
- Accessing the tool's functionality through the REST API for access control and data scanning. (Coming soon...)
97+
98+
## Configuration
99+
100+
Use the [gitleaks configuration](https://github.com/gitleaks/gitleaks#configuration) in this project.
101+
102+
## Document
103+
104+
Run the following code to read the project document.
105+
106+
```shell
107+
cargo doc --document-private-items --open
108+
```
109+
110+
## Contributing
111+
112+
The project relies on community contributions and aims to simplify getting started. To use sensleak-rs, clone the repo, install dependencies, and run sensleak-rs. Pick an issue, make changes, and submit a pull request for community review.
113+
114+
To contribute to rkos, you should:
115+
116+
- Familiarize yourself with the [Code of Conduct](https://github.com/open-rust-initiative/rkos/blob/main/CODE-OF-CONDUCT.md). sensleak-rs has a strict policy against abusive, unethical, or illegal behavior.
117+
- Review the [Contributing Guidelines](https://github.com/open-rust-initiative/rkos/blob/main/CONTRIBUTING.md). This document outlines the process for submitting bug reports, feature requests, and pull requests to sensleak-rs.
118+
- Sign the [Developer Certificate of Origin](https://developercertificate.org) (DCO) by adding a `Signed-off-by` line to your commit messages. This certifies that you wrote or have the right to submit the code you are contributing to the project.
119+
- Choose an issue to work on. Issues labeled `good first issue` are suitable for newcomers. You can also look for issues marked `help wanted`.
120+
- Fork the sensleak-rs repository and create a branch for your changes.
121+
- Make your changes and commit them with a clear commit message.
122+
- Push your changes to GitHub and open a pull request.
123+
- Respond to any feedback on your pull request. The sensleak-rs maintainers will review your changes and may request modifications before merging.
124+
- Once your pull request is merged, you will be listed as a contributor in the project repository and documentation.
125+
126+
To comply with the requirements, contributors must include both a `Signed-off-by` line and a PGP signature in their commit messages. You can find more information about how to generate a PGP key [here](https://docs.github.com/en/github/authenticating-to-github/managing-commit-signature-verification/generating-a-new-gpg-key).
127+
128+
Git even has a `-s` command line option to append this automatically to your commit message, and `-S` to sign your commit with your PGP key. For example:
129+
130+
```shell
131+
$ git commit -S -s -m 'This is my commit message'
132+
```
133+
134+
## License
135+
136+
sensleak-rs is licensed under this licensed:
137+
138+
- MIT LICENSE ( https://opensource.org/licenses/MIT)
139+
140+
## References
141+
142+
1. [What is Gitleaks and how to use it?](https://akashchandwani.medium.com/what-is-gitleaks-and-how-to-use-it-a05f2fb5b034)
143+
2. [Gitleaks.tools](https://github.com/gitleaks/gitleaks)

0 commit comments

Comments
 (0)