func (s *scanRemoteRepoReq) ScanRemoteRepo(iacType, iacVersion string, cloudType []string, policyPath []string) (interface{}, bool, error) {
	var (
		output            interface{}
		err               error
		isAdmissionDenied bool
	)
	tempDir := filepath.Join(os.TempDir(), utils.GenRandomString(6))
	defer os.RemoveAll(tempDir)
	iacDirPath, err := s.d.DownloadWithType(s.RemoteType, s.RemoteURL, tempDir)
	if err != nil {
		errMsg := fmt.Sprintf("failed to download remote repo. error: '%v'", err)
		zap.S().Error(errMsg)
		return output, isAdmissionDenied, err
	}
	executor, err := runtime.NewExecutor(iacType, iacVersion, cloudType,
		"", iacDirPath, policyPath, s.ScanRules, s.SkipRules, s.Categories, s.Severity, s.NonRecursive, false, s.FindVulnerabilities, s.NotificationWebhookURL, s.NotificationWebhookToken, s.RemoteURL, s.RepoRef)
	if err != nil {
		zap.S().Error(err)
		return output, isAdmissionDenied, err
	}
	results, err := executor.Execute(s.ConfigOnly)
	if err != nil {
		errMsg := fmt.Sprintf("failed to scan uploaded file. error: '%v'", err)
		zap.S().Error(errMsg)
		return output, isAdmissionDenied, err
	}
	if s.ConfigOnly {
		output = results.ResourceConfig
	} else {
		if s.RemoteURL != "" {
			results.Violations.Summary.ResourcePath = s.RemoteURL
		}
		if !s.ShowPassed {
			results.Violations.ViolationStore.PassedRules = nil
		}
		isAdmissionDenied = hasK8sAdmissionDeniedViolations(results)
		output = results.Violations
	}
	return output, isAdmissionDenied, nil
}
ScanRemoteRepo is the actual method where a remote repo is downloaded and
scanned for violations
package httpserver
import (
	"encoding/json"
	"fmt"
	"net/http"
	"os"
	"path/filepath"
	"strings"
	"github.com/accurics/terrascan/pkg/config"
	"github.com/accurics/terrascan/pkg/downloader"
	admissionwebhook "github.com/accurics/terrascan/pkg/k8s/admission-webhook"
	"github.com/accurics/terrascan/pkg/runtime"
	"github.com/accurics/terrascan/pkg/utils"
	"github.com/gorilla/mux"
	"go.uber.org/zap"
)
type scanRemoteRepoReq struct {
	RemoteType               string   `json:"remote_type"`
	RemoteURL                string   `json:"remote_url"`
	ConfigOnly               bool     `json:"config_only"`
	ScanRules                []string `json:"scan_rules"`
	SkipRules                []string `json:"skip_rules"`
	Categories               []string `json:"categories"`
	Severity                 string   `json:"severity"`
	ShowPassed               bool     `json:"show_passed"`
	NonRecursive             bool     `json:"non_recursive"`
	FindVulnerabilities      bool     `json:"find_vulnerabilities"`
	d                        downloader.Downloader
	NotificationWebhookURL   string `json:"webhook_url"`
	NotificationWebhookToken string `json:"webhook_token"`
	RepoRef                  string `json:"repo-ref"`
}
func (g *APIHandler) scanRemoteRepo(w http.ResponseWriter, r *http.Request) {
	zap.S().Debug("handle: remote repository scan request")
	params := mux.Vars(r)
	var (
		iacType    = params["iac"]
		iacVersion = params["iacVersion"]
		cloudType  = strings.Split(params["cloud"], ",")
	)
	var s scanRemoteRepoReq
	err := json.NewDecoder(r.Body).Decode(&s)
	if err != nil {
		apiErrorResponse(w, err.Error(), http.StatusBadRequest)
		return
	}
	zap.S().Debugf("scanning remote repository request: %+v", s)
	s.d = downloader.NewDownloader()
	var results interface{}
	var isAdmissionDenied bool
	if g.test {
		results, isAdmissionDenied, err = s.ScanRemoteRepo(iacType, iacVersion, cloudType, []string{"./testdata/testpolicies"})
	} else {
		results, isAdmissionDenied, err = s.ScanRemoteRepo(iacType, iacVersion, cloudType, getPolicyPathFromConfig())
	}
	if err != nil {
		apiErrorResponse(w, err.Error(), http.StatusBadRequest)
		return
	}
	j, err := json.MarshalIndent(results, "", "  ")
	if err != nil {
		errMsg := fmt.Sprintf("failed to create JSON. error: '%v'", err)
		zap.S().Error(errMsg)
		apiErrorResponse(w, errMsg, http.StatusInternalServerError)
		return
	}
	if isAdmissionDenied {
		apiResponse(w, string(j), http.StatusForbidden)
		return
	}
	apiResponse(w, string(j), http.StatusOK)
}