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

support for split model files, restructured to allow import by other projects, improved command line syntax by use of cobra, and more... #57

Merged
merged 73 commits into from
Feb 3, 2024
Merged
Changes from 1 commit
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
28e6264
fixed typos and warnings
joreiche Dec 4, 2023
98882e0
fixed deprecaed and other warnings; fixed spelling
joreiche Dec 5, 2023
7f9f45d
made file paths cross-platform; eliminated IDE warnings; reformatted …
joreiche Dec 6, 2023
18585ce
implemented multi-yaml support
joreiche Dec 15, 2023
7a5366b
added support for directly pointing at the repo demo folders when cre…
joreiche Dec 15, 2023
a3baeea
add install mechanism
joreiche Dec 16, 2023
0233bc4
replace plugins with system calls to regular binaries
joreiche Dec 18, 2023
c7f4eba
modify builtin risks to use model as input parameter
joreiche Dec 18, 2023
ed97925
- made Dockerfile and Dockerfile.local consistent
joreiche Dec 20, 2023
8c2e7b0
converted parse test to go-style testing
joreiche Dec 20, 2023
0785567
moved to go-style folder structure
joreiche Dec 21, 2023
273a867
merged Yevhen's changes
joreiche Dec 22, 2023
2ffb181
Fix comment
Dec 22, 2023
2b634f1
Move create-stub-model, create-example-model, create-editing-support …
Dec 22, 2023
9619c24
Small cleanup
Dec 22, 2023
86a28df
Migrate print license and print 3rd party to cobra
Dec 22, 2023
7af8540
introduced config
joreiche Dec 23, 2023
4977664
Move parsing types closer to type definition
Dec 25, 2023
da977d6
Merge pull request #2 from joreiche/parse-types
ezavgorodniy Dec 25, 2023
b72a226
Move out parsing model code closer to model definition
Dec 25, 2023
4d8b398
Return error instead of panicking
Dec 25, 2023
f4b8aef
converting maps using iskCategory as index to use RiskCategory.Id ins…
joreiche Dec 26, 2023
5ce843a
committing mising file for last commit
joreiche Dec 26, 2023
01186a9
fixed marshaling/unmarshaling parsed model struct from/to json
joreiche Dec 26, 2023
324c639
Move server related files into package
Dec 27, 2023
13fda7c
Merge pull request #3 from joreiche/move-server
ezavgorodniy Dec 27, 2023
50023fc
resolved circular dependencies
joreiche Dec 27, 2023
8f86b3a
Merge branch 'master' of github.com:joreiche/threagile
joreiche Dec 27, 2023
dee5491
completed merge
joreiche Dec 27, 2023
bbe2aea
implemented config file loading and handling
joreiche Dec 27, 2023
d953aa9
Remove server related code from context.go
Jan 4, 2024
25268ff
Remove server related variables from context.go
Jan 4, 2024
aa558e0
Remove modelInput from context object because it's just a variable du…
Jan 4, 2024
7b81de0
Make drawSpaceLinesForLayoutUnfortunatelyFurtherSeparatesAllRanks as …
Jan 4, 2024
68e1e92
Allow to run application with cobra cli
Jan 4, 2024
2e91661
Move one more function out of context
Jan 4, 2024
f391430
Move out graphviz code into report package
Jan 4, 2024
5eb5b5b
Add forgotten file
Jan 5, 2024
027df78
Move parsed model out of context
Jan 5, 2024
6f5de2b
Refactor macros
Jan 5, 2024
c490c6b
Use parameters instead of context
Jan 5, 2024
e4857c2
Move logic to packages
Jan 5, 2024
a45ab19
Remove panic and global variables
Jan 5, 2024
6cdea6d
Remove accidentally uploaded file
Jan 5, 2024
87d8033
Adjust documentation according to changes
Jan 5, 2024
3713215
Inline calls to dot
Jan 5, 2024
87ab8e6
Restore reading config file
Jan 8, 2024
d6bb1c0
Move colors package to report package
Jan 8, 2024
f42969e
Reshuffle files to avoid too much logic inside parsed model, parsedMo…
Jan 8, 2024
3329cd5
Use go interfaces to specify built in risk rules, move custom risk ru…
Jan 9, 2024
77bc549
Tidy up go mod
Jan 9, 2024
8f26d96
- added list of contributors in addition to author to schema and inpu…
joreiche Jan 9, 2024
3e61f05
made sure to propagate build timestamp
joreiche Jan 10, 2024
8967685
made sure to omit empty fields what marshaling inpuyt structs
joreiche Jan 10, 2024
b35e4e9
fixed config file loading
joreiche Jan 24, 2024
dc8d4b0
improved model merging for split model yaml import
joreiche Jan 31, 2024
3d59ffc
improved string list and multi-line merging
joreiche Jan 31, 2024
ac5b4c4
fixed docker run for local docker file
joreiche Jan 31, 2024
6e23605
- added gosec workflow
joreiche Jan 31, 2024
a020fb4
trying to persuade Anchore to use the local code base rather than the…
joreiche Jan 31, 2024
b6bb2fb
upgraded codeql upload action to v2 according to deprecation notice
joreiche Jan 31, 2024
f03ea81
upgraded codeql upload action to v3 according to new deprecation noti…
joreiche Feb 1, 2024
eda8518
manually merged pull request #53
joreiche Feb 2, 2024
6af115d
resolved grype issues:
joreiche Feb 2, 2024
a7a61c6
ignoring grype build errors
joreiche Feb 2, 2024
033fc8a
Stored, sent and received data assets are always processed
Feb 2, 2024
16dfc6d
Merge pull request #4 from joreiche/pr-18-transfer
joreiche Feb 2, 2024
60bb614
manually merged pr #5: Infer CIA ratings of tech assets #19
joreiche Feb 2, 2024
be0dda0
made separate command 'analyze' to analyze a model
joreiche Feb 2, 2024
d45d4b6
added interactive mode
joreiche Feb 2, 2024
428119a
Add tests (red) to test previous commit
Feb 2, 2024
6c481d8
Merge branch 'master' of github.com:joreiche/threagile
joreiche Feb 2, 2024
5f76e14
fixed inference tests
joreiche Feb 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Migrate print license and print 3rd party to cobra
  • Loading branch information
Yevhen Zavhorodnii committed Dec 22, 2023
commit 86a28df252641c6ff634e9678196468b357b791c
42 changes: 42 additions & 0 deletions internal/threagile/about.go
Original file line number Diff line number Diff line change
@@ -4,6 +4,10 @@ Copyright © 2023 NAME HERE <EMAIL ADDRESS>
package threagile

import (
"errors"
"os"
"path/filepath"

"github.com/spf13/cobra"

"github.com/threagile/threagile/pkg/docs"
@@ -14,3 +18,41 @@ var versionCmd = &cobra.Command{
Short: "Get version information",
Long: "\n" + docs.Logo + "\n\n" + docs.VersionText,
}

var print3rdPartyCmd = &cobra.Command{
Use: "print-3rd-party-licenses",
Short: "Print 3rd-party license information",
Long: "\n" + docs.Logo + "\n\n" + docs.VersionText + "\n\n" + docs.ThirdPartyLicenses,
}

var printLicenseCmd = &cobra.Command{
Use: "print-license",
Short: "Print license information",
RunE: func(cmd *cobra.Command, args []string) error {
appDir, err := cmd.Flags().GetString(appDirFlagName)
if err != nil {
cmd.Printf("Unable to read app-dir flag: %v", err)
return err
}
cmd.Println(docs.Logo + "\n\n" + docs.VersionText)
if appDir != filepath.Clean(appDir) {
// TODO: do we need this check here?
cmd.Printf("weird app folder %v", appDir)
return errors.New("weird app folder")
}
content, err := os.ReadFile(filepath.Join(appDir, "LICENSE.txt"))
if err != nil {
cmd.Printf("Unable to read license file: %v", err)
return err
}
cmd.Print(string(content))
cmd.Println()
return nil
},
}

func init() {
rootCmd.AddCommand(versionCmd)
rootCmd.AddCommand(print3rdPartyCmd)
rootCmd.AddCommand(printLicenseCmd)
}
32 changes: 0 additions & 32 deletions internal/threagile/context.go
Original file line number Diff line number Diff line change
@@ -4545,10 +4545,6 @@ func (context *Context) ParseCommandlineArgs() { // folders
context.generateTagsExcel = flag.Bool("generate-tags-excel", true, "generate tags excel")
context.generateReportPDF = flag.Bool("generate-report-pdf", true, "generate report pdf, including diagrams")

// more commands
print3rdParty := flag.Bool("print-3rd-party-licenses", false, "print 3rd-party license information")
license := flag.Bool("print-license", false, "print license information")

flag.Usage = func() {
fmt.Println(docs.Logo + "\n\n" + docs.VersionText)
_, _ = fmt.Fprintf(os.Stderr, "Usage: threagile [options]")
@@ -4574,34 +4570,6 @@ func (context *Context) ParseCommandlineArgs() { // folders
context.progressReporter = CommandLineProgressReporter{}
}

if *print3rdParty {
fmt.Println(docs.Logo + "\n\n" + docs.VersionText)
fmt.Println("Kudos & Credits to the following open-source projects:")
fmt.Println(" - golang (Google Go License): https://golang.org/LICENSE")
fmt.Println(" - go-yaml (MIT License): https://github.com/go-yaml/yaml/blob/v3/LICENSE")
fmt.Println(" - graphviz (CPL License): https://graphviz.gitlab.io/license/")
fmt.Println(" - gofpdf (MIT License): https://github.com/jung-kurt/gofpdf/blob/master/LICENSE")
fmt.Println(" - go-chart (MIT License): https://github.com/wcharczuk/go-chart/blob/master/LICENSE")
fmt.Println(" - excelize (BSD License): https://github.com/qax-os/excelize/blob/master/LICENSE")
fmt.Println(" - graphics-go (BSD License): https://github.com/BurntSushi/graphics-go/blob/master/LICENSE")
fmt.Println(" - google-uuid (BSD License): https://github.com/google/uuid/blob/master/LICENSE")
fmt.Println(" - gin-gonic (MIT License): https://github.com/gin-gonic/gin/blob/master/LICENSE")
fmt.Println(" - swagger-ui (Apache License): https://swagger.io/license/")
fmt.Println()
os.Exit(0)
}
if *license {
fmt.Println(docs.Logo + "\n\n" + docs.VersionText)
if *context.appFolder != filepath.Clean(*context.appFolder) {
log.Fatalf("weird app folder %v", *context.appFolder)
}
content, err := os.ReadFile(filepath.Join(*context.appFolder, "LICENSE.txt"))
checkErr(err)
fmt.Print(string(content))
fmt.Println()
os.Exit(0)
}

context.ServerMode = (*context.serverPort > 0)
}

2 changes: 0 additions & 2 deletions internal/threagile/root.go
Original file line number Diff line number Diff line change
@@ -32,6 +32,4 @@ func init() {
rootCmd.PersistentFlags().String(binDirFlagName, "/app", "binary folder location")
rootCmd.PersistentFlags().String(outputFlagName, ".", "output directory")
rootCmd.PersistentFlags().String(tempDirFlagName, "/tmp", "output directory")

rootCmd.AddCommand(versionCmd)
}
11 changes: 11 additions & 0 deletions pkg/docs/constants.go
Original file line number Diff line number Diff line change
@@ -29,4 +29,15 @@ const (
" docker run --rm -it threagile/threagile -list-model-macros \n\n" +
"If you want to execute a certain model macro on the model yaml file (here the macro add-build-pipeline): \n" +
" docker run --rm -it -v \"$(pwd)\":app/work threagile/threagile -model app/work/threagile.yaml -output app/work -execute-model-macro add-build-pipeline"
ThirdPartyLicenses = " - golang (Google Go License): https://golang.org/LICENSE\n" +
" - go-yaml (MIT License): https://github.com/go-yaml/yaml/blob/v3/LICENSE\n" +
" - graphviz (CPL License): https://graphviz.gitlab.io/license/\n" +
" - gofpdf (MIT License): https://github.com/jung-kurt/gofpdf/blob/master/LICENSE\n" +
" - go-chart (MIT License): https://github.com/wcharczuk/go-chart/blob/master/LICENSE\n" +
" - excelize (BSD License): https://github.com/qax-os/excelize/blob/master/LICENSE\n" +
" - graphics-go (BSD License): https://github.com/BurntSushi/graphics-go/blob/master/LICENSE\n" +
" - google-uuid (BSD License): https://github.com/google/uuid/blob/master/LICENSE\n" +
" - gin-gonic (MIT License): https://github.com/gin-gonic/gin/blob/master/LICENSE\n" +
" - swagger-ui (Apache License): https://swagger.io/license/\n" +
" - cobra-cli (Apache License): https://github.com/spf13/cobra-cli/blob/main/LICENSE.txt\n"
)