Skip to content
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

V2.2+tc pvt #1

Merged
merged 291 commits into from
Aug 21, 2024
Merged

V2.2+tc pvt #1

merged 291 commits into from
Aug 21, 2024

Conversation

2lambda123
Copy link
Owner

@2lambda123 2lambda123 commented Aug 21, 2024

Description

Related Issue

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (non-breaking change that does not add functionality or fix an issue)

Checklist:

  • I have read the Code of Conduct
  • I have updated the documentation accordingly.
  • All commits are GPG signed

Summary by Sourcery

Refactor and enhance the setup scripts for Trust Agent and Attestation Service, introducing new scripts for CIT BKC validation and installation. Improve TPM version handling and modularize setup functions. Remove deprecated scripts to streamline the installation process.

New Features:

  • Introduce a new script for CIT BKC validation to automate hardware and software stack testing for Intel Cloud Integrity Technology.
  • Add a new script for installing CIT Attestation Service and CIT Trust Agent, ensuring all components are installed locally.
  • Implement a new setup script for CIT BKC Tool to manage installation and execution of the tool.

Enhancements:

  • Refactor setup scripts to modularize functions for detecting TPM version and configuring directory layouts.
  • Improve TPM version detection and handling logic in setup scripts for better compatibility with TPM 1.2 and 2.0.
  • Enhance the setup process by adding a script to handle prerequisites installation for the Trust Agent.

Chores:

  • Remove deprecated and unused scripts related to Linux utilities and TPM packages.

Summary by CodeRabbit

  • New Features

    • Enhanced prerequisites management with new setup scripts for the MT Wilson Trust Agent.
    • Introduced the cit-bkc-tool, a command-line utility for Intel Cloud Integrity Technology, providing various functionalities including validation and installation management.
    • Added environment configuration files for Trust Agent and MT Wilson server, detailing critical operational parameters.
  • Bug Fixes

    • Streamlined TPM ownership checks and VMM information retrieval to ensure robustness and prevent errors.
  • Documentation

    • Comprehensive README.md for cit-bkc-tool outlining installation and usage instructions.
    • Added documentation in various new scripts to clarify functionalities and configurations.

Ryan Savino and others added 30 commits August 18, 2016 15:43
…ool' of ssh://git-amr-2.devtools.intel.com:29418/dcg_security-mtwilson into v2.1.0+feature#5600-bkc-tool
…in mtwilson.env to allow local api access for validation script using curl
…CIT BKC Tool installer for generating random passwords
…ls.intel.com:29418/dcg_security-mtwilson into v2.1.0+feature#5600-bkc-tool
…ool' of ssh://git-amr-2.devtools.intel.com:29418/dcg_security-mtwilson into v2.1.0+feature#5600-bkc-tool
…n to functions.sh

added localhost-integration call to tagent.sh
added service restart after localhost-integration call
…nable localhost access to apis via shiro authentication
…ool' of ssh://git-amr-2.devtools.intel.com:29418/dcg_security-mtwilson into v2.1.0+feature#5600-bkc-tool
…changed to move shiro-localhost.ini file to shiro.ini file location
…ool' of ssh://git-amr-2.devtools.intel.com:29418/dcg_security-mtwilson into v2.1.0+feature#5600-bkc-tool
…lias which forces prompt

commented out "else" statement to prevent syntax error
…ddressed the code review feedback from Ryan and also updated the script to use xmlstarlet instead of sed.
…cause functions.sh is in common-java and this copy was breaking the build
…ool' of ssh://git-amr-2.devtools.intel.com:29418/dcg_security-mtwilson into v2.1.0+feature#5600-bkc-tool

# Conflicts:
#	installers/LinuxUtil/src/files/functions.sh
…5600-bkc-tool

# Conflicts:
#	installers/LinuxUtil/pom.xml (removed: functions.sh is in common-java, mtwilson.sh is now in mtwilson-server)
#	installers/mtwilson-trustagent/src/files/setup_prereqs.sh (merged)
#	trust-agent/mtwilson-trustagent-setup/src/main/java/com/intel/mtwilson/trustagent/setup/CreateTpmOwnerSecret.java (merged)
Ryan Savino and others added 12 commits October 20, 2016 13:08
…ool' of ssh://git-amr-2.devtools.intel.com:29418/dcg_security-mtwilson into v2.1.0+feature#5600-bkc-tool
…' into v2.1.0+feature#5600-bkc-tool

# Conflicts:
#	trust-agent/mtwilson-trustagent-console/src/main/java/com/intel/mtwilson/trustagent/cmd/StartHttpServer.java
…bkc-tool' into dev-cit-2.2+feature#5600-bkc-tool
…v-cit-2.2+feature#5600-bkc-tool

Conflicts:
	installers/LinuxUtil/src/files/functions.sh
…5600-bkc-tool' of ssh://git-amr-2.devtools.intel.com:29418/dcg_security-mtwilson into dev-cit-2.2+feature#5600-bkc-tool
Copy link

Unable to locate .performanceTestingBot config file

Copy link

cr-gpt bot commented Aug 21, 2024

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

Copy link

git-greetings bot commented Aug 21, 2024

Thanks @2lambda123 for opening this PR!

For COLLABORATOR only :

  • To add labels, comment on the issue
    /label add label1,label2,label3

  • To remove labels, comment on the issue
    /label remove label1,label2,label3

Copy link

Processing PR updates...

Copy link

@gitginie gitginie bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@2lambda123
Thank you for your contribution to this repository! We appreciate your effort in opening pull request.
Happy coding!

Copy link

quine-bot bot commented Aug 21, 2024

👋 Figuring out if a PR is useful is hard, hopefully this will help.

  • @2lambda123 has been on GitHub since 2019 and in that time has had 2612 public PRs merged
  • They haven't contributed to this repo before
  • Here's a good example of their work: black-forest-labs-flux
  • From looking at their profile, they seem to be good with Python and Makefile.

Their most recently public accepted PR is: 2lambda123/crypto-com-curve25519-dalek#4

Copy link

codeautopilot bot commented Aug 21, 2024

Your organization has reached the subscribed usage limit. You can upgrade your account by purchasing a subscription at Stripe payment link

Disclaimer: This comment was entirely generated using AI. Be aware that the information provided may be incorrect.

Current plan usage: 117.00%

Have feedback or need help?
Discord
Documentation
support@codeautopilot.com

Copy link

git-greetings bot commented Aug 21, 2024

First PR by @2lambda123

PR Details of @2lambda123 in opencit-opencit :

OPEN CLOSED TOTAL
1 0 1

Copy link

sourcery-ai bot commented Aug 21, 2024

Reviewer's Guide by Sourcery

This pull request implements several changes to improve the installation and setup process for the CIT (Cloud Integrity Technology) components, including the Trust Agent and Attestation Service. The changes focus on streamlining the installation process, improving error handling, and adding support for TPM 2.0.

File-Level Changes

Files Changes
installers/mtwilson-trustagent/src/files/setup.sh
installers/mtwilson-trustagent-rhel/src/files/setup.sh
installers/mtwilson-server/src/files/setup.sh
Refactored the setup scripts for both Trust Agent and Attestation Service to improve modularity and error handling
installers/mtwilson-trustagent/src/files/setup.sh
installers/mtwilson-trustagent-rhel/src/files/setup.sh
Added support for TPM 2.0 detection and configuration
installers/mtwilson-trustagent/src/files/setup_prereqs.sh
installers/mtwilson-trustagent-rhel/src/files/setup_prereqs.sh
Introduced new setup_prereqs.sh scripts for handling prerequisites installation
installers/mtwilson-trustagent/src/files/setup_prereqs.sh
installers/mtwilson-trustagent-rhel/src/files/setup_prereqs.sh
Updated GRUB configuration process to support both UEFI and legacy boot modes
packages/cit-bkc-tool/src/main/linux/cit-bkc-validation.sh
packages/cit-bkc-tool/src/main/linux/cit-bkc-tool.sh
Implemented a new CIT BKC (Best Known Configuration) tool for validating platform readiness
packages/cit-bkc-tool/src/main/linux/install_cit_service.sh
packages/cit-bkc-tool/src/main/linux/install_cit_agent.sh
Added separate installation scripts for CIT Attestation Service and Trust Agent
services/mtwilson-saml/src/main/java/com/intel/mtwilson/saml/SamlGenerator.java Updated SAML generation to remove dependency on local host address lookup
integration/mtwilson-api/src/main/java/com/intel/mtwilson/datatypes/HostVMMType.java Modified HostVMMType enum to temporarily support both CIT 2.1 and 2.2 configurations
trust-agent/mtwilson-trustagent-ws-v2/src/main/java/com/intel/mountwilson/trustagent/commands/hostinfo/HostInfoCmd.java Updated Trust Agent web service to set default VMM name and version when not detected

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

@2lambda123 2lambda123 merged commit 8e40c62 into release-cit-2.2 Aug 21, 2024
10 of 19 checks passed
Copy link

@gitginie gitginie bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@2lambda123
Thank you for your contribution to this repository! We appreciate your effort in closing pull request.
Happy coding!

Copy link

coderabbitai bot commented Aug 21, 2024

Warning

Rate limit exceeded

@labels-and-badges[bot] has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 12 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 069bb50 and 05a9f49.

Walkthrough

The changes introduced in this update enhance the functionality, error handling, and dependency management of multiple components within the MT Wilson project ecosystem. Key updates involve modifications to installation scripts, more robust configuration management, and improved integration processes for security features. These enhancements collectively aim to bolster the overall robustness and user experience of the system, ensuring smoother operations for the Attestation service and related tools.

Changes

File Paths Change Summary
installers/.../setup.sh, installers/.../setup_prereqs.sh Updated installation scripts for prerequisite handling, package management, and user interactions.
installers/.../pom.xml Removed obsolete dependencies and added new ones for better dependency management and configuration.
installers/.../mtwilson.sh Altered integration cases to focus on Shiro configuration and service restarts, improving localhost integration handling.
packages/cit-bkc-tool/... Introduced new scripts for managing CIT BKC tool operations, including validation, installation, and configuration management.
trust-agent/... Refined TPM ownership checks and enhanced VMM handling to ensure robustness and prevent null reference issues.
services/mtwilson-saml/.../SamlGenerator.java Updated method to retrieve host addresses via configuration rather than DNS lookup for enhanced reliability.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Installer
    participant Configuration
    participant Service

    User->>Installer: Initiate installation
    Installer->>Configuration: Load configuration
    Configuration-->>Installer: Config values
    Installer->>Service: Start service
    Service-->>Installer: Service started
    Installer-->>User: Installation complete
Loading

🐇 In the meadow, changes bloom,
With scripts that whisk away the gloom.
From packages new to dependencies bright,
Each hop brings progress, oh what a sight!
In the world of tech, we take our chance,
With every code line, we do a happy dance! 🐰✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@labels-and-badges labels-and-badges bot added NO JIRA This PR does not have a Jira Ticket PR:size/XXL Denotes a Pull Request that changes 1000+ lines. labels Aug 21, 2024
Comment on lines 115 to 116
auto_install "Developer tools" "DEVELOPER" >> "$INSTALL_LOG_FILE"
if [ $? -ne 0 ]; then echo_failure "Failed to install prerequisites through package installer"; exit -1; fi

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of exit -1 is not standard for indicating failure in shell scripts. The standard exit code for general errors is 1. Using -1 can lead to confusion and is not portable across different systems.

Recommended Solution: Replace exit -1 with exit 1 to follow standard conventions for exit codes.

Comment on lines 523 to +526
localhost-integration)
mtwilson_localhost_integration $@
#mtwilson_localhost_integration $@
shiro_localhost_integration "/opt/mtwilson/configuration/shiro.ini"
/opt/mtwilson/bin/mtwilson.sh restart

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The localhost-integration case calls shiro_localhost_integration and then immediately restarts the service using /opt/mtwilson/bin/mtwilson.sh restart. If shiro_localhost_integration fails for any reason, the script will still proceed to restart the service, which could lead to inconsistent states or failures.

Recommendation: Add error handling to check the exit status of shiro_localhost_integration before proceeding to restart the service. If the command fails, the script should exit or handle the error appropriately.

Comment on lines +171 to +188
<!--
<artifactItem>
<groupId>net.sourceforge.tboot</groupId>
<artifactId>tboot</artifactId>
<version>1.9.4</version>
<classifier>x86_64</classifier>
<type>rpm</type>
<outputDirectory>${makeself.directory}</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>net.sourceforge.tboot</groupId>
<artifactId>tboot</artifactId>
<version>1.9.4</version>
<classifier>amd64</classifier>
<type>deb</type>
<outputDirectory>${makeself.directory}</outputDirectory>
</artifactItem>
-->

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented-out code blocks can lead to confusion and clutter in the codebase. If the commented-out dependencies are no longer needed, they should be removed. If they might be needed in the future, consider documenting the reason for their presence and any conditions under which they should be uncommented.

Recommended Solution: Remove the commented-out code if it is no longer necessary, or add a comment explaining why it is kept and under what conditions it should be used.

Comment on lines +83 to +98
<!--
<dependency>
<groupId>net.sourceforge.tboot</groupId>
<artifactId>tboot</artifactId>
<version>1.9.4</version>
<classifier>x86_64</classifier>
<type>rpm</type>
</dependency>
<dependency>
<groupId>net.sourceforge.tboot</groupId>
<artifactId>tboot</artifactId>
<version>1.9.4</version>
<classifier>amd64</classifier>
<type>deb</type>
</dependency>
-->

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented-out dependencies for tboot are present in the POM file. If these dependencies are no longer needed, they should be removed to keep the POM file clean and maintainable. If they might be needed in the future, consider documenting the reason for keeping them commented out.

Comment on lines +194 to +211
<!--
<artifactItem>
<groupId>net.sourceforge.tboot</groupId>
<artifactId>tboot</artifactId>
<version>1.9.4</version>
<classifier>x86_64</classifier>
<type>rpm</type>
<outputDirectory>${makeself.directory}</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>net.sourceforge.tboot</groupId>
<artifactId>tboot</artifactId>
<version>1.9.4</version>
<classifier>amd64</classifier>
<type>deb</type>
<outputDirectory>${makeself.directory}</outputDirectory>
</artifactItem>
-->

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented-out artifact items for tboot are present in the POM file. If these artifact items are no longer needed, they should be removed to keep the POM file clean and maintainable. If they might be needed in the future, consider documenting the reason for keeping them commented out.

Comment on lines +84 to +87
if [ $result -eq 255 ] || [ -f "/opt/mtwilson/var/reboot_required" ]; then
rm -f /opt/mtwilson/var/reboot_required
echo_info "CIT Attestation Service requires reboot to continue";
exit 255

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script exits with code 255 if a reboot is required, but it does not provide any mechanism to resume the installation after the reboot. This could lead to incomplete installations if the user does not manually restart the script.

Recommended Solution: Implement a mechanism to resume the installation automatically after a reboot, such as creating a flag file that the script checks for and continues from where it left off.

Comment on lines +6 to +10
MTWILSON_ADMIN_PASSWORD=
MTWILSON_DATABASE_PASSWORD=
MTWILSON_PRIVACYCA_PASSWORD=
MTWILSON_TAG_ADMIN_PASSWORD=
MTWILSON_TAG_XML_PASSWORD=

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sensitive information such as passwords (MTWILSON_ADMIN_PASSWORD, MTWILSON_DATABASE_PASSWORD, MTWILSON_PRIVACYCA_PASSWORD, MTWILSON_TAG_ADMIN_PASSWORD, MTWILSON_TAG_XML_PASSWORD) are being stored in environment variables. This can be a security risk as environment variables can be accessed by any process running with the same user privileges.

Recommendation: Use a secure secrets management service or tool to handle sensitive information instead of storing them in environment variables. If environment variables must be used, ensure they are set in a secure manner and access is restricted.

# 2. run the "install.sh" script from the destination folder
# that script will run subordinate installers and automatically resume after reboot

source ./cit-bkc-tool.env

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using source in a script that starts with #!/bin/sh can lead to compatibility issues because source is not POSIX-compliant and may not be available in all shell environments. Instead, use the POSIX-compliant . (dot) command to source the file.

Comment on lines +14 to +16
rm -rf $CIT_BKC_PACKAGE_PATH
mkdir -p $CIT_BKC_PACKAGE_PATH
cp * $CIT_BKC_PACKAGE_PATH

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script uses rm -rf and cp * without proper validation or quoting, which can lead to unintended deletions or copying of files, especially if filenames contain spaces or special characters. Always quote variables and consider adding checks to ensure the paths and filenames are safe.

MTWILSON_TLS_CERT_SHA1=
MTWILSON_TLS_CERT_SHA256=<MTWILSON_TLS_CERT_SHA256>
MTWILSON_API_USERNAME=pca-admin
MTWILSON_API_PASSWORD=password

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Storing sensitive information such as MTWILSON_API_PASSWORD directly in the environment file is a security risk. This can lead to unauthorized access if the file is exposed.

Recommended Solution: Use a secure secrets management service or environment variable injection mechanism to handle sensitive information. Ensure that the password is not hardcoded and is securely retrieved at runtime.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @2lambda123 - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • Potential hard-coded secret: admin password generation. (link)
  • Potential hard-coded secret: database password generation. (link)
  • Potential hard-coded secret: Privacy CA password generation. (link)
  • Potential hard-coded secret: tag admin password generation. (link)
  • Potential hard-coded secret: tag XML password generation. (link)
  • Potential hard-coded secret: API password update. (link)

Overall Comments:

  • This is a substantial refactoring that improves modularity and TPM 2.0 support. Please ensure thorough testing has been done on both TPM 1.2 and 2.0 systems, as well as different Linux distributions.
  • The new CIT BKC Tool looks like a valuable addition for validating deployments. Consider adding some documentation or user guide for this new tool.
  • The removal of the LinuxUtil scripts represents a significant change. Make sure all functionality has been properly migrated to the new scripts and nothing important was lost in the transition.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🔴 Security: 6 blocking issues, 2 other issues
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟡 Documentation: 1 issue found

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

}

cit_bkc_print_env() {
env | grep -E "^CIT_BKC|^http_proxy|^https_proxy"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 suggestion (security): Consider safer alternative to 'eval' for environment variables

The use of 'eval' to load environment variables can be risky. Consider using a safer method to parse and set environment variables.

Suggested change
env | grep -E "^CIT_BKC|^http_proxy|^https_proxy"
cit_bkc_print_env() {
printenv | grep -E "^(CIT_BKC|http_proxy|https_proxy)="
}

# identify tpm version
# postcondition:
# variable TPM_VERSION is set to 1.2 or 2.0
detect_tpm_version() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider using a more robust method for TPM version detection

The current method relies on file checks, which might not be reliable across all systems. Consider using system commands or libraries specifically designed for TPM detection to ensure accuracy.

detect_tpm_version() {
  export TPM_VERSION
  if command -v tpm2_getcap >/dev/null 2>&1; then
    TPM_VERSION="2.0"
  elif command -v tpm_version >/dev/null 2>&1; then
    TPM_VERSION="1.2"
  else
    echo "Unable to detect TPM version" >&2
    return 1
  fi
}

if [ -z "$target" ] || [ ! -f "$target" ]; then return 1; fi
source "$target"
local env_file_exports=$(cat "$target" | grep -E '^[A-Z0-9_]+\s*=' | cut -d = -f 1)
if [ -n "$env_file_exports" ]; then eval export $env_file_exports; fi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 issue (security): Replace eval with a safer alternative for exporting variables

Using eval to export variables from an environment file is a potential security risk if the file contains malicious content. Consider using a safer approach, such as parsing the file line by line and exporting variables individually.

chmod +x *.sh *.bin

pwd=$(pwd)
if [ "$pwd" != "$CIT_BKC_PACKAGE_PATH" ]; then
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Avoid hardcoded paths and allow for configuration

The script uses hardcoded paths like $CIT_BKC_PACKAGE_PATH. Consider allowing these to be configured or use relative paths where possible to improve flexibility and maintainability.

Suggested change
if [ "$pwd" != "$CIT_BKC_PACKAGE_PATH" ]; then
if [ "$pwd" != "${CIT_BKC_PACKAGE_PATH:-$HOME/cit_bkc_package}" ]; then
CIT_BKC_PACKAGE_PATH="${CIT_BKC_PACKAGE_PATH:-$HOME/cit_bkc_package}"

Comment on lines +6 to +7
This tool tests the platform hardware and software stack to validate that
it is ready for Intel(R) Cloud Integrity Technology.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (documentation): Consider consistent capitalization for product name

Ensure 'Intel(R) Cloud Integrity Technology' is capitalized consistently throughout the document. The first mention uses all caps, while this one doesn't.

cp $CIT_BKC_PACKAGE_PATH/mtwilson.env $HOME/mtwilson.env
local admin_passwd=$(generate_password 16)
update_property_in_file MTWILSON_ADMIN_PASSWORD $HOME/mtwilson.env "$admin_passwd"
local database_passwd=$(generate_password 16)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 issue (security): Potential hard-coded secret: database password generation.

Ensure that the generated database password is securely stored and not exposed in logs or error messages.

update_property_in_file MTWILSON_ADMIN_PASSWORD $HOME/mtwilson.env "$admin_passwd"
local database_passwd=$(generate_password 16)
update_property_in_file MTWILSON_DATABASE_PASSWORD $HOME/mtwilson.env "$database_passwd"
local pca_passwd=$(generate_password 16)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 issue (security): Potential hard-coded secret: Privacy CA password generation.

Ensure that the generated Privacy CA password is securely stored and not exposed in logs or error messages.

update_property_in_file MTWILSON_DATABASE_PASSWORD $HOME/mtwilson.env "$database_passwd"
local pca_passwd=$(generate_password 16)
update_property_in_file MTWILSON_PRIVACYCA_PASSWORD $HOME/mtwilson.env "$pca_passwd"
local tag_passwd=$(generate_password 16)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 issue (security): Potential hard-coded secret: tag admin password generation.

Ensure that the generated tag admin password is securely stored and not exposed in logs or error messages.

update_property_in_file MTWILSON_PRIVACYCA_PASSWORD $HOME/mtwilson.env "$pca_passwd"
local tag_passwd=$(generate_password 16)
update_property_in_file MTWILSON_TAG_ADMIN_PASSWORD $HOME/mtwilson.env "$tag_passwd"
local tagxml_passwd=$(generate_password 16)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 issue (security): Potential hard-coded secret: tag XML password generation.

Ensure that the generated tag XML password is securely stored and not exposed in logs or error messages.

update_property_in_file MTWILSON_TLS_CERT_SHA1 $HOME/trustagent.env "$tls_sha1"
update_property_in_file MTWILSON_TLS_CERT_SHA256 $HOME/trustagent.env "$tls_sha256"
pca_passwd=$(read_property_from_file MTWILSON_PRIVACYCA_PASSWORD $HOME/mtwilson.env)
update_property_in_file MTWILSON_API_PASSWORD $HOME/trustagent.env "$pca_passwd"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 issue (security): Potential hard-coded secret: API password update.

Ensure that the API password is securely stored and not exposed in logs or error messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NO JIRA This PR does not have a Jira Ticket PR:size/XXL Denotes a Pull Request that changes 1000+ lines. size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants