Skip to content

Conversation

@kartikeysemwal
Copy link

Fixes #129
The code changes include new -srd flag. The directory will be used to save all the output files, such textOutput, htmlOutput, indexResponses and raw response. Earlier all these file used to be saved in the "output-cariddi" in the same directory.

Fixes #130
The output path of the stored response will also be printed in the json output if -json flag is enabled

@auto-assign auto-assign bot requested a review from edoardottt August 17, 2024 11:00
@kartikeysemwal kartikeysemwal mentioned this pull request Aug 17, 2024
2 tasks
@edoardottt
Copy link
Owner

Hi @kartikeysemwal ! Thanks for your work and contribution. Really appreciated.

Two actions are failing (go build and linter). Please fix them before I start a review : )

If you need any help/assistance I'm here !

@kartikeysemwal
Copy link
Author

kartikeysemwal commented Aug 27, 2024

@edoardottt updated according to the workflow errors, could you please rerun and check

@edoardottt edoardottt self-assigned this Aug 27, 2024
Copy link
Owner

@edoardottt edoardottt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first review

}

config.OutputDir = output.CariddiOutputFolder
if flags.StoredRespDir != "" {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should perform some tests. What if config.StoreResp is not specified?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the two tags -sr and -srd, there are four possible scenarios:

  1. Both -sr and -srd are not set:

    • No HTTP response will be saved.
    • OutputDir will be set to its default value, and any other data that needs to be saved will be stored in this directory.
  2. Only -sr is set:

    • The HTTP response, along with any other data, will be saved in the OutputDir, which will be the default directory.
  3. Only -srd is set:

    • Everything, including the HTTP response, will be saved to the OutputDir provided with the -srd flag.
  4. Both -sr and -srd are set:

    • Everything will be saved to the OutputDir provided with the -srd flag.

In the config struct, I have used the StoreResp boolean as the key indicator of whether to store the response. Therefore, if the user provides only the -srd flag, we will set StoreResp to true.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can understand point 3 and 4 are the same right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, just in point 3 we will set the StoreResp value to true

if os.IsNotExist(err) {
if _, err := os.Stat("output-cariddi/"); os.IsNotExist(err) {
CreateOutputFolder()
if _, err := os.Stat(outputDir + "/"); os.IsNotExist(err) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's better to use Sprintf

if os.IsNotExist(err) {
if _, err := os.Stat("output-cariddi/"); os.IsNotExist(err) {
CreateOutputFolder()
if _, err := os.Stat(outputDir + "/"); os.IsNotExist(err) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sprintf

rng := rand.New(source)

decision := rng.Intn(100)
const maxRandomValue = 100
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put all constants at the top of this file.

Like

const (
    maxRandomValue = 100
)

"github.com/edoardottt/cariddi/pkg/scanner"
)

// constant defined in file.go as well, redefining here for circular dependency.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't possible to define just one constant somewhere (file / output) and import that?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the PR. This comment was incorrect, constant is defined just once so removed the comment.

@edoardottt
Copy link
Owner

any update on this review?

@kartikeysemwal
Copy link
Author

Hi @edoardottt, yes I will update the PR by weekend. But do we agree on StoreResp part in the first review comment.

@edoardottt
Copy link
Owner

Hi @edoardottt, yes I will update the PR by weekend. But do we agree on StoreResp part in the first review comment.

yes, we do :)

@kartikeysemwal
Copy link
Author

@edoardottt , PR is updated, incase you missed

Copy link
Owner

@edoardottt edoardottt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the syntax + coding best practices side t's okay.
I think we need more unit tests before an actual try. For example, does the changes handle weird (or even unacceptable) input for output folder?
Before the PR changes output-cariddi was used, so no problem on that side. What if I use !%&/&%$\"$%&&/%&(&(=7909 as input?
Oc this is just an example, but we need to understand what could be wrong.

Let me know your thoughts on this,
edoardo

@kartikeysemwal
Copy link
Author

yes I agree with you. Let me add some layer of validation and test cases accordingly.

@kartikeysemwal
Copy link
Author

@edoardottt , update the PR based on review

@edoardottt
Copy link
Owner

Hi @kartikeysemwal , both Go / build and golangci-lint / lint actions are failing

@kartikeysemwal
Copy link
Author

@edoardottt, I have updated the PR. Apologies for the inconvenience. The build failures were specific to the Linux system, and I initially created the PR on a Windows machine. Unfortunately, my WSL is currently broken, so I wasn't able to verify the new commit locally.

@edoardottt edoardottt changed the base branch from main to devel February 6, 2025 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants