Documentation
      ¶
    
    
  
    
  
    Index ¶
- func BoolPtr(b bool) *bool
 - func ByteStringToBase64(data []byte) string
 - func CalculateMd5(filePath string) (string, error)
 - func DecodeBase64ToString(ctx context.Context, encoded string) types.String
 - func ExtractGUIDFromString(stringToExtractFrom string) (string, error)
 - func GetEnvBool(k string, defaultValue bool) bool
 - func GetEnvInt64(k string, defaultValue types.Int64) types.Int64
 - func GetEnvString(k string, defaultValue string) string
 - func GetEnvStringSlice(k string, defaultValue []string) []string
 - func GetFirstEnvString(ks []string, defaultValue string) string
 - func IsDebugMode() bool
 - func JoinWithSeparator(strs []string, sep string) string
 - func ParseCertificateData(ctx context.Context, certData []byte, password []byte) ([]*x509.Certificate, crypto.PrivateKey, error)
 - func ParseHCLFile(filePath string) (string, error)
 - func ParseJSONFile(filePath string) (string, error)
 - func SplitCommaSeparatedString(s string) []string
 - func StringPtr(s string) *string
 - func StringToBase64(input string) (string, error)
 - func StringToInt(str string, mapping map[string]int) (int, error)
 
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByteStringToBase64 ¶
ByteStringToBase64 converts a byte slice to a base64-encoded string
func CalculateMd5 ¶
CalculateMd5 calculates the MD5 checksum of a file.
func DecodeBase64ToString ¶
DecodeBase64ToString decodes a base64-encoded string and returns a Terraform Framework string. If decoding fails, it logs a warning and returns the original string as fallback.
func ExtractGUIDFromString ¶
ExtractGUIDFromString extracts a GUID from the beginning of a string.
func GetEnvBool ¶
GetEnvBool is a helper function that returns the boolean value of the given environment variable, if one exists, or the default value otherwise.
func GetEnvInt64 ¶
GetEnvInt64 is a helper function that returns the types.Int64Value of the given environment variable, if one exists, or the default value otherwise.
func GetEnvString ¶
GetEnvString is a helper function that returns the value of the given environment variable, if one exists, or the default value otherwise.
func GetEnvStringSlice ¶
GetEnvStringSlice is a helper function that returns a slice of strings based on the environment variable (if set) or the provided default value. The environment variable should be a comma-separated string.
func GetFirstEnvString ¶
GetFirstEnvString is a helper function that returns the value of the first environment variable in the given list that returns a non-empty value. If none of the environment variables return a value, the default value is returned.
func IsDebugMode ¶
func IsDebugMode() bool
IsDebugMode checks if the M365_DEBUG_MODE environment variable is set to true
func JoinWithSeparator ¶
JoinWithSeparator joins a slice of strings with the specified separator
func ParseCertificateData ¶
func ParseCertificateData(ctx context.Context, certData []byte, password []byte) ([]*x509.Certificate, crypto.PrivateKey, error)
ParseCertificateData decodes and parses PKCS#12 data, extracting certificates and a private key.
This function attempts to decode PKCS#12 data using the provided password. It extracts the certificate chain (including the end-entity certificate and any CA certificates), as well as the private key associated with the end-entity certificate.
The function performs several validations: - It checks if any certificates are present in the decoded data. - It verifies the presence of a private key. - It ensures the private key is of RSA type.
The function logs debug, error, and info messages at various stages of the process.
Parameters:
- ctx: A context.Context for logging and potential cancellation.
 - certData: A byte slice containing the PKCS#12 data to be parsed.
 - password: A byte slice containing the password to decrypt the PKCS#12 data.
 
Returns:
- []*x509.Certificate: A slice of parsed X.509 certificates, with the end-entity certificate as the first element, followed by any CA certificates.
 - crypto.PrivateKey: The private key associated with the end-entity certificate.
 - error: An error if any step of the parsing or validation process fails. This will be nil if the function executes successfully.
 
Possible errors:
- Failure to parse PKCS#12 data
 - No certificates found in the PKCS#12 data
 - No private key found in the PKCS#12 data
 - Private key is not of RSA type
 
Usage example:
certs, privKey, err := ParseCertificateData(ctx, pkcs12Data, []byte("password"))
if err != nil {
    // Handle error
}
// Use certs and privKey as needed
  
        func ParseHCLFile ¶
ParseHCLFile securely loads a Terraform configuration file from the specified path. Security measures: - Validates file extensions (.tf, .hcl) - Prevents path traversal attacks - Restricts access to files within the project directory - Comprehensive error logging and validation
func ParseJSONFile ¶
ParseJSONFile securely loads a JSON file from the specified path. Security measures: - Validates file extensions (.json) - Prevents path traversal attacks - Restricts access to files within the project directory - Comprehensive error logging and validation
func SplitCommaSeparatedString ¶
SplitCommaSeparatedString splits a comma-separated string into a slice of strings
func StringToBase64 ¶
StringToBase64 encodes the input string to base64.
Types ¶
This section is empty.