<commit_before>package main

import (
	"crypto/rand"
	"crypto/x509"
	"crypto/x509/pkix"
	"encoding/pem"
	"encoding/xml"
	"fmt"
	"io/ioutil"
	"math/big"
	"net/http"
	"net/url"
	"strings"
	"time"

	"github.com/Cloud-Foundations/keymaster/lib/certgen"

	"github.com/aws/aws-sdk-go-v2/aws/arn"
)

type parsedArnType struct {
	parsedArn arn.ARN
	role      string
}

type getCallerIdentityResult struct {
	Arn string
}

type getCallerIdentityResponse struct {
	GetCallerIdentityResult getCallerIdentityResult
}

func getCallerIdentity(presignedUrl string,
	presignedMethod string) (*parsedArnType, error) {
	parsedPresignedUrl, err := url.Parse(presignedUrl)
	if err != nil {
		return nil, err
	}<commit_msg>Add more checks on presigned URL.<commit_after>package main

import (
	"crypto/rand"
	"crypto/x509"
	"crypto/x509/pkix"
	"encoding/pem"
	"encoding/xml"
	"fmt"
	"io/ioutil"
	"math/big"
	"net/http"
	"net/url"
	"strings"
	"time"

	"github.com/Cloud-Foundations/keymaster/lib/certgen"

	"github.com/aws/aws-sdk-go-v2/aws/arn"
)

type parsedArnType struct {
	parsedArn arn.ARN
	role      string
}

type getCallerIdentityResult struct {
	Arn string
}

type getCallerIdentityResponse struct {
	GetCallerIdentityResult getCallerIdentityResult
}

func getCallerIdentity(presignedUrl string,
	presignedMethod string) (*parsedArnType, error) {
	parsedPresignedUrl, err := url.Parse(presignedUrl)
	if err != nil {
		return nil, err
	}
	if parsedPresignedUrl.Scheme != "https" {
		return nil, fmt.Errorf("invalid scheme: %s", parsedPresignedUrl.Scheme)
	}
	if parsedPresignedUrl.Path != "/" {
		return nil, fmt.Errorf("invalid path: %s", parsedPresignedUrl.Path)
	}
	if !strings.HasPrefix(parsedPresignedUrl.RawQuery,
		"Action=GetCallerIdentity&") {
		return nil,
			fmt.Errorf("invalid action: %s", parsedPresignedUrl.RawQuery)
	}
{'fraction_non_alphanumeric': 0.12300933552992861, 'fraction_numerical': 0.007688083470620538, 'mean_word_length': 4.729559748427673, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5969907', 'n_tokens_mistral': 709, 'n_tokens_neox': 684, 'n_words': 131}