Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/s0md3v/hardcodes
find hardcoded strings from source code
https://github.com/s0md3v/hardcodes
Last synced: about 1 month ago
JSON representation
find hardcoded strings from source code
- Host: GitHub
- URL: https://github.com/s0md3v/hardcodes
- Owner: s0md3v
- License: gpl-3.0
- Created: 2020-06-02T15:44:43.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-02-03T16:21:39.000Z (almost 3 years ago)
- Last Synced: 2024-10-04T18:45:20.912Z (2 months ago)
- Language: Python
- Size: 23.4 KB
- Stars: 273
- Watchers: 9
- Forks: 35
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-hacking-lists - s0md3v/hardcodes - find hardcoded strings from source code (Python)
README
hardcodes
extract strings from source code
**hardcodes** is a utility for searching strings hardcoded by developers in programs. It uses a modular tokenizer that can handle comments, any number of backslashes & nearly any syntax you throw at it.
Yes, it is designed to process any syntax and following languages are officially supported:
```
ada, applescript, c, c#, c++, coldfusion, golang, haskell, html, java, javascript,
jsp, lua, pascal, perl, php, powershell, python, ruby, scala, sql, swift, xml
```#### Installation
##### with pip
```
pip3 install hardcodes
```
##### or build from source
```
git clone https://github.com/s0md3v/hardcodes && cd hardcodes && python3 setup.py install
```
### Documentation
hardcodes is available as both a library as well as a command line program. The relevant documentation can be found below:- [For developers](https://github.com/s0md3v/hardcodes#for-developers)
- [For users](https://github.com/s0md3v/hardcodes#for-users)### For Developers
The sample program below demonstrates usage of `hardcodes` library```python
from hardcodes import searchstring = "console.log('hello there')"
result = search(string, lang="common", comments="parse")
print(result)
```
```python
Output: ['hello there']
```The arguments `lang` and `comments` are optional. Their use is explained below in the user documentation section.
### For Users
`cli.py` provides a grep-like command line interface to `hardcodes` library. You will need to install the library first to use it.#### Find strings in a file
```bash
python cli.py /path/to/file.ext
```#### Find strings in a directory, recursively
```bash
python cli.py -r /path/to/dir
```#### Hide paths from output
```bash
python cli.py -o /path/to/file.ext
```#### Specify programming language
Specifying a language is optional and should be used only when the programming language of source is already known.```bash
python cli.py -l 'golang' /path/to/file.go
```#### Specify comment behaviour
With `-c` option, you can specify- `ignore` ignore the comments completely
- `parse` parse the comments like code
- `string` add comments to list of hardcoded strings`python cli.py -o /path/to/file.ext`