Skip to content

Conversation

@parrasajad
Copy link
Contributor

No description provided.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Member

@ehsandeep ehsandeep left a comment

Choose a reason for hiding this comment

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

This seems to be fix the issue, however here an edge case causing a crash.

echo test | ./notify -bulk -cl 1

             __  _ ___    
  ___  ___  / /_(_) _/_ __
 / _ \/ _ \/ __/ / _/ // /
/_//_/\___/\__/_/_/ \_, / v1.0.2-dev
                   /___/  

		projectdiscovery.io

Use with caution. You are responsible for your actions
Developers assume no liability and are not responsible for any misuse or damage.
Using default provider config: /Users/geekboy/.config/notify/provider-config.yaml
panic: runtime error: slice bounds out of range [:-2]

goroutine 1 [running]:
github.com/projectdiscovery/notify/internal/runner.bulkSplitter.func1({0x1400032fc60, 0x5, 0x5}, 0x0)
	/Users/geekboy/Github/notify/internal/runner/util.go:36 +0x2e8
bufio.(*Scanner).Scan(0x1400031fe18)
	/opt/homebrew/Cellar/go/1.18.2/libexec/src/bufio/scan.go:147 +0xac
github.com/projectdiscovery/notify/internal/runner.(*Runner).Run(0x14000323020)
	/Users/geekboy/Github/notify/internal/runner/runner.go:112 +0x5b8
main.main()
	/Users/geekboy/Github/notify/cmd/notify/notify.go:42 +0x184

@justinsteven
Copy link
Contributor

stdin is still broken:

% id | ./notify

             __  _ ___
  ___  ___  / /_(_) _/_ __
 / _ \/ _ \/ __/ / _/ // /
/_//_/\___/\__/_/_/ \_, / v1.0.2-dev
                   /___/

                projectdiscovery.io

Use with caution. You are responsible for your actions
Developers assume no liability and are not responsible for any misuse or damage.
Using default provider config: /home/justin/.config/notify/provider-config.yaml

It's also causing files, when sent in -bulk mode, to have a trailing newline:

% cat AAAA
AAAA
% ./notify -bulk -i AAAA

             __  _ ___
  ___  ___  / /_(_) _/_ __
 / _ \/ _ \/ __/ / _/ // /
/_//_/\___/\__/_/_/ \_, / v1.0.2-dev
                   /___/

                projectdiscovery.io

Use with caution. You are responsible for your actions
Developers assume no liability and are not responsible for any misuse or damage.
Using default provider config: /home/justin/.config/notify/provider-config.yaml
AAAA

%

Finally the change here doesn't seem relevant to the changes in #146 which introduced the problems. Returning 0, nil, nil is correct as it's a special signal to the Scanner that more data is needed to produce a chunk. Perhaps us cranking up the buffer size in #146 means that we won't get a case where we need more data from the Scanner, but this means that the SplitFunc is now not re-usable elsewhere, and we shouldn't be cranking up the buffer size anyway, in doing so we're losing the benefit of using a Scanner which is to be able to stream data in in a memory-efficient way.

I'm sorry for being critical but I don't think this should be merged, and I think #146 needs to be reworked.

@justinsteven
Copy link
Contributor

Aha

  • stdin fails on Linux for any input size
  • stdin fails on macOS for small inputs
  • stdin fails on macOS for large inputs (confirmed with a 9000 byte input)

That might be contributing to the confusion around stdin being broken

#146 stat's the input to get its size so as to set the buffer size. On Linux, and on macOS with large inputs, stdin has a reported size of 0.

I will look to rework #146 when I get a chance

@Mzack9999 Mzack9999 added the Status: On Hold Similar to blocked, but is assigned to someone label Jun 12, 2022
@Mzack9999
Copy link
Member

Mzack9999 commented Jun 12, 2022

Thanks @justinsteven for having a look at this. I'm marking the PR on hold until #150 gets reviewed superseded by #150

@Mzack9999 Mzack9999 added the Status: Abandoned This issue is no longer important to the requestor and no one else has shown an interest in it. label Jun 13, 2022
@ehsandeep ehsandeep closed this Jun 13, 2022
@ehsandeep ehsandeep deleted the bulk-mode-fix branch June 13, 2022 11:50
@ehsandeep ehsandeep removed the Status: On Hold Similar to blocked, but is assigned to someone label Jun 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Abandoned This issue is no longer important to the requestor and no one else has shown an interest in it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

-bulk mode doesn't work with input length less than char-limit -char-limit is not honoured in non-bulk mode

5 participants