Formatting

This commit is contained in:
Alvaro Muñoz
2023-09-11 16:55:32 +02:00
parent 81de79e4c8
commit 361fa7c833
5 changed files with 122 additions and 122 deletions

View File

@@ -5,16 +5,16 @@ Copyright © 2023 NAME HERE <EMAIL ADDRESS>
package cmd
import (
"sync"
"errors"
"fmt"
"github.com/GitHubSecurityLab/gh-mrva/config"
"github.com/GitHubSecurityLab/gh-mrva/models"
"github.com/GitHubSecurityLab/gh-mrva/utils"
"log"
"os"
"path/filepath"
"strings"
"log"
"github.com/GitHubSecurityLab/gh-mrva/utils"
"github.com/GitHubSecurityLab/gh-mrva/models"
"github.com/GitHubSecurityLab/gh-mrva/config"
"sync"
"github.com/spf13/cobra"
)

View File

@@ -22,9 +22,9 @@ THE SOFTWARE.
package cmd
import (
"os"
"log"
"github.com/GitHubSecurityLab/gh-mrva/utils"
"log"
"os"
"path/filepath"
"github.com/spf13/cobra"
@@ -32,8 +32,10 @@ import (
var (
sessionNameFlag string
runIdFlag int
sessionPrefixFlag string
outputDirFlag string
outputFilenameFlag string
downloadDBsFlag bool
nwoFlag string
jsonFlag bool

View File

@@ -1,6 +1,5 @@
/*
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
*/
package cmd
@@ -9,11 +8,10 @@ import (
"log"
"os"
"github.com/spf13/cobra"
"github.com/GitHubSecurityLab/gh-mrva/utils"
"github.com/GitHubSecurityLab/gh-mrva/config"
"github.com/GitHubSecurityLab/gh-mrva/models"
"github.com/GitHubSecurityLab/gh-mrva/utils"
"github.com/spf13/cobra"
)
var (
@@ -159,4 +157,3 @@ func submitQuery() {
}
fmt.Println("Done!")
}

View File

@@ -2,26 +2,27 @@ package utils
import (
"archive/zip"
"sync"
"text/template"
"github.com/google/uuid"
"bufio"
"bytes"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"github.com/google/uuid"
"gopkg.in/yaml.v3"
"io"
"log"
"os"
"os/exec"
"path/filepath"
"strings"
"os/exec"
"bytes"
"encoding/json"
"fmt"
"sync"
"text/template"
"time"
"os"
"gopkg.in/yaml.v3"
"io/ioutil"
"log"
"errors"
"github.com/GitHubSecurityLab/gh-mrva/models"
"github.com/cli/go-gh"
"github.com/cli/go-gh/pkg/api"
"github.com/GitHubSecurityLab/gh-mrva/models"
)
var (
@@ -46,7 +47,7 @@ func SetConfigFilePath(path string) {
}
func GetSessions() (map[string]models.Session, error) {
sessionsFile, err := ioutil.ReadFile(sessionsFilePath)
sessionsFile, err := os.ReadFile(sessionsFilePath)
var sessions map[string]models.Session
if err != nil {
return sessions, err
@@ -148,7 +149,7 @@ func SaveSession(name string, controller string, runs []models.Run, language str
return err
}
// write sessions to file
err = ioutil.WriteFile(sessionsFilePath, sessionsYaml, os.ModePerm)
err = os.WriteFile(sessionsFilePath, sessionsYaml, os.ModePerm)
if err != nil {
return err
}
@@ -189,7 +190,7 @@ func SubmitRun(controller string, language string, repoChunk []string, bundle st
}
func GetConfig() (models.Config, error) {
configFile, err := ioutil.ReadFile(configFilePath)
configFile, err := os.ReadFile(configFilePath)
var configData models.Config
if err != nil {
return configData, err
@@ -208,7 +209,7 @@ func ResolveRepositories(listFile string, list string) ([]string, error) {
return nil, err
}
defer jsonFile.Close()
byteValue, _ := ioutil.ReadAll(jsonFile)
byteValue, _ := io.ReadAll(jsonFile)
var repoLists map[string][]string
err = json.Unmarshal(byteValue, &repoLists)
if err != nil {
@@ -288,7 +289,7 @@ func GenerateQueryPack(codeqlPath string, queryFile string, language string) (st
fmt.Printf("Generating query pack for %s\n", queryFile)
// create a temporary directory to hold the query pack
queryPackDir, err := ioutil.TempDir("", "query-pack-")
queryPackDir, err := os.MkdirTemp("", "query-pack-")
if err != nil {
log.Fatal(err)
}
@@ -406,7 +407,7 @@ defaultSuite:
return "", "", fmt.Errorf("Failed to open bundle file: %v\n", err)
}
defer bundleFile.Close()
bundleBytes, err := ioutil.ReadAll(bundleFile)
bundleBytes, err := io.ReadAll(bundleFile)
if err != nil {
return "", "", fmt.Errorf("Failed to read bundle file: %v\n", err)
}
@@ -449,7 +450,7 @@ func FindPackRoot(queryFile string) string {
func FixPackFile(queryPackDir string, packRelativePath string) error {
packPath := filepath.Join(queryPackDir, "qlpack.yml")
packFile, err := ioutil.ReadFile(packPath)
packFile, err := os.ReadFile(packPath)
if err != nil {
return err
}
@@ -490,7 +491,7 @@ func FixPackFile(queryPackDir string, packRelativePath string) error {
if err != nil {
return err
}
err = ioutil.WriteFile(packPath, packFile, 0644)
err = os.WriteFile(packPath, packFile, 0644)
if err != nil {
return err
}
@@ -502,11 +503,11 @@ func CopyFile(srcPath string, targetPath string) error {
if err != nil {
return err
}
bytesRead, err := ioutil.ReadFile(srcPath)
bytesRead, err := os.ReadFile(srcPath)
if err != nil {
return err
}
err = ioutil.WriteFile(targetPath, bytesRead, 0644)
err = os.WriteFile(targetPath, bytesRead, 0644)
if err != nil {
return err
}
@@ -538,7 +539,7 @@ func downloadArtifact(url string, outputDir string, nwo string) error {
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
@@ -557,7 +558,7 @@ func downloadArtifact(url string, outputDir string, nwo string) error {
log.Fatal(err)
}
defer f.Close()
bytes, err := ioutil.ReadAll(f)
bytes, err := io.ReadAll(f)
if err != nil {
log.Fatal(err)
}
@@ -569,7 +570,7 @@ func downloadArtifact(url string, outputDir string, nwo string) error {
extension = "sarif"
}
resultPath = filepath.Join(outputDir, fmt.Sprintf("%s.%s", strings.Replace(nwo, "/", "_", -1), extension))
err = ioutil.WriteFile(resultPath, bytes, os.ModePerm)
err = os.WriteFile(resultPath, bytes, os.ModePerm)
if err != nil {
return err
}
@@ -608,11 +609,11 @@ func DownloadDatabase(nwo string, language string, outputDir string) error {
}
defer resp.Body.Close()
bytes, err := ioutil.ReadAll(resp.Body)
bytes, err := io.ReadAll(resp.Body)
if err != nil {
return err
}
err = ioutil.WriteFile(targetPath, bytes, os.ModePerm)
err = os.WriteFile(targetPath, bytes, os.ModePerm)
return nil
}