
소스 코드에서 하드코딩된 문자열 찾기
hardcodes는 개발자가 프로그램에 하드코딩한 문자열을 검색하는 유틸리티입니다. 모듈식 토크나이저를 사용하여 주석, 모든 수의 백슬래시 및 거의 모든 구문을 처리할 수 있습니다.
네, 모든 구문을 처리하도록 설계되었으며 다음 언어가 공식적으로 지원됩니다:
ada, applescript, c, c#, c++, coldfusion, golang, haskell, html, java, javascript,
jsp, lua, pascal, perl, php, powershell, python, ruby, scala, sql, swift, xml
pip3 install hardcodes
git clone https://github.com/s0md3v/hardcodes && cd hardcodes && python3 setup.py install
hardcodes는 라이브러리와 명령줄 프로그램 모두로 사용할 수 있습니다. 관련 문서는 아래에서 확인할 수 있습니다:
아래 샘플 프로그램은 hardcodes 라이브러리의 사용법을 보여줍니다
from hardcodes import search
string = "console.log('hello there')"
result = search(string, lang="common", comments="parse")
print(result)
Output: ['hello there']
lang 및 comments 인수는 선택 사항입니다. 이들의 사용법은 아래 사용자 문서 섹션에서 설명합니다.
cli.py는 hardcodes 라이브러리에 대한 grep과 유사한 명령줄 인터페이스를 제공합니다. 사용하려면 먼저 라이브러리를 설치해야 합니다.
python cli.py /path/to/file.ext
python cli.py -r /path/to/dir
python cli.py -o /path/to/file.ext
언어 지정은 선택 사항이며, 소스의 프로그래밍 언어가 이미 알려진 경우에만 사용해야 합니다.
python cli.py -l 'golang' /path/to/file.go
-c 옵션을 사용하면 다음을 지정할 수 있습니다:
ignore 주석을 완전히 무시parse 주석을 코드처럼 파싱string 하드코딩된 문자열 목록에 주석 추가python cli.py -o /path/to/file.ext