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

Could not find the documentation on "How to write the config file" #537

Closed
NishikaDeSilva opened this issue Oct 28, 2020 · 8 comments
Closed

Comments

@NishikaDeSilva
Copy link

NishikaDeSilva commented Oct 28, 2020

Summary

I want to exclude false-positives using the config file in GoSec. I understand that this can be done by giving the option -config . However, there is no proper detailed documentation on the syntax of writing this file.

Is there any documentation other than readme on this? If not can you please make a detailed document?

@ccojocar
Copy link
Member

ccojocar commented Nov 2, 2020

We have some documentation on this website https://securego.io/docs/rules/rule-intro.html, which is stored in this repository https://github.com/securego/securego.github.io but the config part is not covered.

Happy to accept a pull request if you are willing to contribute. Please just reach out to me on slack if you need any help.

@nanikjava
Copy link
Contributor

@ccojocar what needs to be done for the documentation ? keen to help out for this ticket.

@ccojocar
Copy link
Member

@nanikjava You can try to add some documentation for configuration keys in https://github.com/securego/securego.github.io. These are some places to check in the code where the configuration is parsed:

It would be also nice to add in the docs a sample file for configuration.

@nanikjava
Copy link
Contributor

@ccojocar Going through the above mentioned code found that the complete JSON file will look like this

{
  "global": {
    "nosec": true,
    "audit" : "enabled",
    "show-ignored" : true,
    "#nosec" : "#falsePositive"
  }
}

Is this correct ?

@ccojocar
Copy link
Member

ccojocar commented Aug 22, 2021

I think there are a few more config flags. For instance each rule can be enabled/disabled.

You can search trough the code to find all invocations of

func (c Config) Get(section string) (interface{}, error)

and

func (c Config) GetGlobal(option GlobalOption) (string, error)

@nanikjava
Copy link
Contributor

Went through the code as you suggested found the following for Set(..) and Get(..) (both inside config_test.go)

		It("should be possible to save configuration to file", func() {
			configuration.Set("G101", map[string]string{
				"mode": "strict",
			})

			buffer := bytes.NewBuffer([]byte{})
			nbytes, err := configuration.WriteTo(buffer)
			Expect(int(nbytes)).ShouldNot(BeZero())
			Expect(err).ShouldNot(HaveOccurred())
			Expect(buffer.String()).Should(Equal(`{"G101":{"mode":"strict"},"global":{}}`))
		})
	})
	Context("when configuring rules", func() {
		It("should be possible to get configuration for a rule", func() {
			settings := map[string]string{
				"ciphers": "AES256-GCM",
			}
			configuration.Set("G101", settings)

			retrieved, err := configuration.Get("G101")
			Expect(err).ShouldNot(HaveOccurred())
			Expect(retrieved).Should(HaveKeyWithValue("ciphers", "AES256-GCM"))
			Expect(retrieved).ShouldNot(HaveKey("foobar"))
		})
	})

Is this what you referring to ?

@ccojocar
Copy link
Member

Yeah, some rules have specific settings (e.g. hardcoded credentials).

@ccojocar
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants