Repository navigation
fix: audit risk #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: audit risk #113
Changes from 15 commits
e7bd2d5
059d189
19aab58
9eeee01
cd111a7
1ef64a5
9a09c88
651bf0e
6c0a705
8dd7dbf
8bd0859
4f6cab8
340ca25
fbd685d
9e4f617
54ba1e5
e36653d
2c67861
6442b91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -272,7 +272,10 @@ genesis.block = { | |
| } | ||
|
|
||
| localwitness = [ | ||
| # address TPL66VK2gCXNCD7EJg9pgJRfqcRazjhUZY | ||
| # IMPORTANT: This is a DEMO private key for local testing ONLY | ||
| # Address: TPL66VK2gCXNCD7EJg9pgJRfqcRazjhUZY | ||
| # WARNING: Replace with your own generated key for any real deployment | ||
| # NEVER use this key on mainnet with real funds | ||
| da146374a75310b9666e834ee4ad0866d6f4035967bfc76217c5a495fff9f0d0 # you must enable this value and the witness address are match. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. better not, because it will cause user cannot start the demo easily. I already mention it in related readme. |
||
| ] | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -274,7 +274,10 @@ genesis.block = { | |
| } | ||
|
|
||
| localwitness = [ | ||
| # address TCjptjyjenNKB2Y6EwyVT43DQyUUorxKWi | ||
| # IMPORTANT: This is a DEMO private key for local testing ONLY | ||
| # Address: TCjptjyjenNKB2Y6EwyVT43DQyUUorxKWi | ||
| # WARNING: Replace with your own generated key for any real deployment | ||
| # NEVER use this key on mainnet with real funds | ||
| 0ab0b4893c83102ed7be35eee6d50f081625ac75a07da6cb58b1ad2e9c18ce43 # you must enable this value and the witness address are match. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above, for user quick-start |
||
| ] | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,40 @@ | ||
| # SECURITY WARNING: This file contains sensitive configuration for remote node deployment. | ||
| # DO NOT commit actual credentials, SSH keys, or real hostnames to the repository. | ||
| # Use environment variables, .env files (added to .gitignore), or secure credential management systems. | ||
| # See: https://12factor.net/config | ||
| # | ||
| # Example configuration for private network layout: | ||
|
|
||
| # [[nodes]] | ||
| # node_ip = "192.168.1.1" # Remote node's IP | ||
| # node_ip = "127.0.0.1" # Remote node's IP | ||
| # node_directory = "/path/to/direcotry" # Remote node's working direcotry for node | ||
| # config_file = "/path/to/config" # Config file for remote node | ||
| # docker_compose_file =”/path/to/config“ # Config docker-compose file for remote node | ||
| # docker_compose_file ="/path/to/config" # Config docker-compose file for remote node | ||
| # node_type = "fullnode/sr" # Fullnode or SR node | ||
| # ssh_port = 22 | ||
| # ssh_user = "user1" | ||
| # ssh_password = "password1" # Optional; uncomment if using password auth | ||
| # # ssh_key = "/path/to/key1" # Optional; uncomment if using key auth | ||
|
|
||
| # [[nodes]] | ||
| # node_ip = "192.168.1.2" # Changed IP to demonstrate different nodes | ||
| # node_ip = "127.0.0.1" # Changed IP to demonstrate different nodes | ||
| # node_directory = "/path/to/directory" | ||
| # config_file = "/path/to/config" | ||
| # docker_compose_file =”/path/to/config“ # Config docker-compose file for remote node | ||
| # docker_compose_file ="/path/to/config" # Config docker-compose file for remote node | ||
| # node_type = "fullnode/sr" | ||
| # ssh_port = 2222 # Custom SCP port for this node | ||
| # ssh_user = "user2" | ||
| # # No password or key; assumes SSH agent or pre-configured key | ||
|
|
||
|
|
||
| [[nodes]] | ||
| node_ip = "ec2-3-25-116-244.ap-southeast-2.compute.amazonaws.com" | ||
| node_directory = "/home/ubuntu/mytest" | ||
| config_file = "/Users/ubuntu/conf/private_net_config_others.conf" | ||
| docker_compose_file = "/Users/ubuntu/docker-compose.yml" | ||
| node_ip = "127.0.0.1" # Replace with your actual node IP or hostname | ||
| node_directory = "/path/to/tron-node" # Replace with your actual node directory | ||
| config_file = "/path/to/private_net_config.conf" # Replace with your actual config path | ||
| docker_compose_file = "/path/to/docker-compose.yml" # Replace with your actual docker-compose path | ||
| ssh_port = 22 | ||
| ssh_user = "ubuntu" | ||
| # ssh_password = "password1" | ||
| ssh_key = "/Users/ubuntu/Downloads/test-ci.pem" # Optional; uncomment if using key auth | ||
| ssh_user = "ubuntu" # Replace with your actual SSH user | ||
| # ssh_password = "password" # Optional; uncomment if using password auth (NOT RECOMMENDED) | ||
| # ssh_key = "/path/to/your/private/key" # Optional; uncomment if using key auth | ||
| # SECURITY WARNING: Never commit actual SSH keys or private credentials to the repository! | ||
| # Use environment variables or secure credential management systems instead. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,64 +1,67 @@ | ||
| #!/bin/sh | ||
| #!/bin/bash | ||
| set -eu # exit on any error | ||
|
|
||
| # Define the URL for the Checkstyle JAR file | ||
| # ─── Configuration ─── | ||
| CHECKSTYLE_VERSION="8.42" | ||
| CHECKSTYLE_JAR="checkstyle-${CHECKSTYLE_VERSION}-all.jar" | ||
| CHECKSTYLE_URL="https://github.com/checkstyle/checkstyle/releases/download/checkstyle-${CHECKSTYLE_VERSION}/${CHECKSTYLE_JAR}" | ||
|
|
||
| # Define the directory where the JAR file should be stored | ||
| LIB_DIR="libs" | ||
| # SHA-256 digest of the official release JAR | ||
| # Obtain from: https://github.com/checkstyle/checkstyle/releases/tag/checkstyle-8.42 | ||
| # or run: sha256sum checkstyle-8.42-all.jar | ||
| CHECKSTYLE_SHA256="4982ebeaa429fe41f3be2c3309a5c49d84c71ee1f78f967344b8bc82cf3101aa" | ||
|
|
||
| # Create the directory if it does not exist | ||
| LIB_DIR="libs" | ||
| mkdir -p "$LIB_DIR" | ||
|
|
||
| # Define the full path to the JAR file | ||
| CHECKSTYLE_PATH="${LIB_DIR}/${CHECKSTYLE_JAR}" | ||
|
|
||
| # Check if the JAR file already exists | ||
| # ─── Download with integrity verification ─── | ||
| verify_checksum() { | ||
| local file="$1" | ||
| local expected="$2" | ||
| local actual | ||
| actual=$(sha256sum "$file" | awk '{print $1}') | ||
| if [ "$actual" != "$expected" ]; then | ||
| echo "ERROR: Checksum mismatch for ${file}" >&2 | ||
| echo " Expected: ${expected}" >&2 | ||
| echo " Actual: ${actual}" >&2 | ||
| rm -f "$file" | ||
| exit 1 | ||
| fi | ||
| echo "Checksum verified: ${file}" | ||
| } | ||
|
|
||
| if [ -f "$CHECKSTYLE_PATH" ]; then | ||
| echo "Checkstyle JAR file already exists at ${CHECKSTYLE_PATH}" | ||
| echo "Checkstyle JAR exists at ${CHECKSTYLE_PATH}, verifying integrity..." | ||
| verify_checksum "$CHECKSTYLE_PATH" "$CHECKSTYLE_SHA256" | ||
| else | ||
| echo "Checkstyle JAR file not found. Downloading from ${CHECKSTYLE_URL}..." | ||
| curl -L -o "$CHECKSTYLE_PATH" "$CHECKSTYLE_URL" && echo "downloaded successfully" | ||
| echo "Downloading Checkstyle from ${CHECKSTYLE_URL}..." | ||
| curl --fail --silent --show-error -L -o "$CHECKSTYLE_PATH" "$CHECKSTYLE_URL" | ||
| verify_checksum "$CHECKSTYLE_PATH" "$CHECKSTYLE_SHA256" | ||
| echo "Downloaded and verified successfully." | ||
| fi | ||
|
|
||
| # Add the lib directory to .gitignore if it's not already present | ||
| # ─── .gitignore handling ─── | ||
| GITIGNORE_FILE=".gitignore" | ||
|
|
||
| if ! grep -q "^${LIB_DIR}/$" "$GITIGNORE_FILE"; then | ||
| echo "Adding ${LIB_DIR}/ to ${GITIGNORE_FILE}" | ||
| if [ -f "$GITIGNORE_FILE" ] && ! grep -q "^${LIB_DIR}/$" "$GITIGNORE_FILE"; then | ||
| echo "${LIB_DIR}/" >> "$GITIGNORE_FILE" | ||
| else | ||
| echo "${LIB_DIR}/ is already in ${GITIGNORE_FILE}" | ||
| fi | ||
|
|
||
| # Check if there are any Java files in the project | ||
| JAVA_FILES_FOUND=$(find . -name "*.java") | ||
| # ─── Find and check Java files ─── | ||
| CHECKSTYLE_CONFIG="./conf/checkstyle/checkStyleAll.xml" | ||
|
|
||
| # if there is java file go ahead to trigger checkStyle for all java files | ||
| if [ -z "$JAVA_FILES_FOUND" ]; then | ||
| echo "No Java files found in the project." | ||
| # Use find with -print0 / xargs -0 to handle filenames with spaces | ||
| JAVA_COUNT=$(find . -name "*.java" | wc -l) | ||
| if [ "$JAVA_COUNT" -eq 0 ]; then | ||
| echo "No Java files found." | ||
| exit 0 | ||
| else | ||
| echo "Java files found in the project. Now run further checks." | ||
| fi | ||
|
|
||
| # Path to your Checkstyle configuration file | ||
| CHECKSTYLE_CONFIG="./conf/checkstyle/checkStyleAll.xml" | ||
|
|
||
| # shellcheck disable=SC2027 | ||
| # shellcheck disable=SC2046 | ||
|
|
||
| All_Java_Files=$(find . -name "*.java") | ||
|
|
||
| # Run Checkstyle on all Java files in the repository | ||
| java -jar "$CHECKSTYLE_PATH" -c "$CHECKSTYLE_CONFIG" "$All_Java_Files" | ||
|
|
||
| echo "finish ...." | ||
| echo "Found ${JAVA_COUNT} Java files, running Checkstyle..." | ||
|
|
||
| # Capture the exit code of Checkstyle | ||
| # shellcheck disable=SC2320 | ||
| # Capture exit code correctly (not after echo) | ||
| find . -name "*.java" -print0 | xargs -0 java -jar "$CHECKSTYLE_PATH" -c "$CHECKSTYLE_CONFIG" | ||
| STATUS=$? | ||
|
|
||
| # Exit with the same status code as Checkstyle | ||
| echo "Checkstyle finished with exit code: ${STATUS}" | ||
| exit $STATUS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this workflows actually not used yet, so just modify the file and configure later