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

Validate the request #4588

Merged
merged 1 commit into from
Feb 8, 2024
Merged

Validate the request #4588

merged 1 commit into from
Feb 8, 2024

Conversation

yeasy
Copy link
Member

@yeasy yeasy commented Jan 3, 2024

The patchset adds validation to the request before using it.

Change-Id: Ic6a7a65d6da289d84fe82c3f6e048e396b1f1a0e

Type of change

  • Improvement (improvement to code, performance, etc)

Description

The patchset adds validation to the request before using it.

This can help protect from malformed request.

Additional details

N/A

Related issues

N/A

Release Note

N/A

@yeasy yeasy requested a review from a team as a code owner January 3, 2024 22:04
internal/pkg/gateway/commitstatus.go Outdated Show resolved Hide resolved
internal/pkg/gateway/commitstatus.go Outdated Show resolved Hide resolved
internal/pkg/gateway/commitstatus.go Outdated Show resolved Hide resolved
internal/pkg/gateway/commitstatus.go Outdated Show resolved Hide resolved
@C0rWin
Copy link
Contributor

C0rWin commented Jan 17, 2024

    --- FAIL: TestCommitStatus/error_finding_transaction_status (0.00s)
        api_test.go:552: 
            	Error Trace:	/home/runner/work/fabric/fabric/internal/pkg/gateway/api_test.go:552
            	            				/home/runner/work/fabric/fabric/internal/pkg/gateway/commitstatus_test.go:135
            	Error:      	Error "rpc error: code = InvalidArgument desc = no identity provided" does not contain "FINDER_ERROR"
            	Test:       	TestCommitStatus/error_finding_transaction_status
            	Messages:   	error string
    --- FAIL: TestCommitStatus/returns_transaction_status (0.00s)
        commitstatus_test.go:140: 
            	Error Trace:	/home/runner/work/fabric/fabric/internal/pkg/gateway/commitstatus_test.go:140
            	Error:      	Received unexpected error:
            	            	rpc error: code = InvalidArgument desc = no identity provided
            	Test:       	TestCommitStatus/returns_transaction_status
    --- FAIL: TestCommitStatus/passes_channel_name_to_finder (0.00s)
        commitstatus_test.go:140: 
            	Error Trace:	/home/runner/work/fabric/fabric/internal/pkg/gateway/commitstatus_test.go:140
            	Error:      	Received unexpected error:
            	            	rpc error: code = InvalidArgument desc = no identity provided
            	Test:       	TestCommitStatus/passes_channel_name_to_finder
    --- FAIL: TestCommitStatus/passes_transaction_ID_to_finder (0.00s)
        commitstatus_test.go:140: 
            	Error Trace:	/home/runner/work/fabric/fabric/internal/pkg/gateway/commitstatus_test.go:140
            	Error:      	Received unexpected error:
            	            	rpc error: code = InvalidArgument desc = no identity provided
            	Test:       	TestCommitStatus/passes_transaction_ID_to_finder
    --- FAIL: TestCommitStatus/failed_policy_or_signature_check (0.00s)
        api_test.go:552: 
            	Error Trace:	/home/runner/work/fabric/fabric/internal/pkg/gateway/api_test.go:552
            	            				/home/runner/work/fabric/fabric/internal/pkg/gateway/commitstatus_test.go:135
            	Error:      	Error "rpc error: code = InvalidArgument desc = no identity provided" does not contain "POLICY_ERROR"
            	Test:       	TestCommitStatus/failed_policy_or_signature_check
            	Messages:   	error string
    --- FAIL: TestCommitStatus/passes_channel_name_to_policy_checker (0.00s)
        commitstatus_test.go:140: 
            	Error Trace:	/home/runner/work/fabric/fabric/internal/pkg/gateway/commitstatus_test.go:140
            	Error:      	Received unexpected error:
            	            	rpc error: code = InvalidArgument desc = no identity provided
            	Test:       	TestCommitStatus/passes_channel_name_to_policy_checker
    --- FAIL: TestCommitStatus/context_timeout (0.00s)
        api_test.go:552: 
            	Error Trace:	/home/runner/work/fabric/fabric/internal/pkg/gateway/api_test.go:552
            	            				/home/runner/work/fabric/fabric/internal/pkg/gateway/commitstatus_test.go:135
            	Error:      	Error "rpc error: code = InvalidArgument desc = no identity provided" does not contain "context deadline exceeded"
            	Test:       	TestCommitStatus/context_timeout
            	Messages:   	error string
    --- FAIL: TestCommitStatus/context_canceled (0.00s)
        api_test.go:552: 
            	Error Trace:	/home/runner/work/fabric/fabric/internal/pkg/gateway/api_test.go:552
            	            				/home/runner/work/fabric/fabric/internal/pkg/gateway/commitstatus_test.go:135
            	Error:      	Error "rpc error: code = InvalidArgument desc = no identity provided" does not contain "context canceled"
            	Test:       	TestCommitStatus/context_canceled
            	Messages:   	error string

@yeasy I think you also need to update the tests to adjust to your changes.

@yeasy
Copy link
Member Author

yeasy commented Jan 22, 2024

    --- FAIL: TestCommitStatus/error_finding_transaction_status (0.00s)
        api_test.go:552: 
            	Error Trace:	/home/runner/work/fabric/fabric/internal/pkg/gateway/api_test.go:552
            	            				/home/runner/work/fabric/fabric/internal/pkg/gateway/commitstatus_test.go:135
            	Error:      	Error "rpc error: code = InvalidArgument desc = no identity provided" does not contain "FINDER_ERROR"
            	Test:       	TestCommitStatus/error_finding_transaction_status
            	Messages:   	error string
    --- FAIL: TestCommitStatus/returns_transaction_status (0.00s)
        commitstatus_test.go:140: 
            	Error Trace:	/home/runner/work/fabric/fabric/internal/pkg/gateway/commitstatus_test.go:140
            	Error:      	Received unexpected error:
            	            	rpc error: code = InvalidArgument desc = no identity provided
            	Test:       	TestCommitStatus/returns_transaction_status
    --- FAIL: TestCommitStatus/passes_channel_name_to_finder (0.00s)
        commitstatus_test.go:140: 
            	Error Trace:	/home/runner/work/fabric/fabric/internal/pkg/gateway/commitstatus_test.go:140
            	Error:      	Received unexpected error:
            	            	rpc error: code = InvalidArgument desc = no identity provided
            	Test:       	TestCommitStatus/passes_channel_name_to_finder
    --- FAIL: TestCommitStatus/passes_transaction_ID_to_finder (0.00s)
        commitstatus_test.go:140: 
            	Error Trace:	/home/runner/work/fabric/fabric/internal/pkg/gateway/commitstatus_test.go:140
            	Error:      	Received unexpected error:
            	            	rpc error: code = InvalidArgument desc = no identity provided
            	Test:       	TestCommitStatus/passes_transaction_ID_to_finder
    --- FAIL: TestCommitStatus/failed_policy_or_signature_check (0.00s)
        api_test.go:552: 
            	Error Trace:	/home/runner/work/fabric/fabric/internal/pkg/gateway/api_test.go:552
            	            				/home/runner/work/fabric/fabric/internal/pkg/gateway/commitstatus_test.go:135
            	Error:      	Error "rpc error: code = InvalidArgument desc = no identity provided" does not contain "POLICY_ERROR"
            	Test:       	TestCommitStatus/failed_policy_or_signature_check
            	Messages:   	error string
    --- FAIL: TestCommitStatus/passes_channel_name_to_policy_checker (0.00s)
        commitstatus_test.go:140: 
            	Error Trace:	/home/runner/work/fabric/fabric/internal/pkg/gateway/commitstatus_test.go:140
            	Error:      	Received unexpected error:
            	            	rpc error: code = InvalidArgument desc = no identity provided
            	Test:       	TestCommitStatus/passes_channel_name_to_policy_checker
    --- FAIL: TestCommitStatus/context_timeout (0.00s)
        api_test.go:552: 
            	Error Trace:	/home/runner/work/fabric/fabric/internal/pkg/gateway/api_test.go:552
            	            				/home/runner/work/fabric/fabric/internal/pkg/gateway/commitstatus_test.go:135
            	Error:      	Error "rpc error: code = InvalidArgument desc = no identity provided" does not contain "context deadline exceeded"
            	Test:       	TestCommitStatus/context_timeout
            	Messages:   	error string
    --- FAIL: TestCommitStatus/context_canceled (0.00s)
        api_test.go:552: 
            	Error Trace:	/home/runner/work/fabric/fabric/internal/pkg/gateway/api_test.go:552
            	            				/home/runner/work/fabric/fabric/internal/pkg/gateway/commitstatus_test.go:135
            	Error:      	Error "rpc error: code = InvalidArgument desc = no identity provided" does not contain "context canceled"
            	Test:       	TestCommitStatus/context_canceled
            	Messages:   	error string

@yeasy I think you also need to update the tests to adjust to your changes.

Fixed now.

@yeasy yeasy force-pushed the validate_request branch 2 times, most recently from db2f5ea to 8c68f29 Compare January 22, 2024 19:11
@C0rWin
Copy link
Contributor

C0rWin commented Jan 28, 2024

    --- FAIL: TestCommitStatus/error_finding_transaction_status (0.00s)
        api_test.go:552: 
            	Error Trace:	/home/runner/work/fabric/fabric/internal/pkg/gateway/api_test.go:552
            	            				/home/runner/work/fabric/fabric/internal/pkg/gateway/commitstatus_test.go:135
            	Error:      	Error "rpc error: code = InvalidArgument desc = no identity provided" does not contain "FINDER_ERROR"
            	Test:       	TestCommitStatus/error_finding_transaction_status
            	Messages:   	error string
    --- FAIL: TestCommitStatus/returns_transaction_status (0.00s)
        commitstatus_test.go:140: 
            	Error Trace:	/home/runner/work/fabric/fabric/internal/pkg/gateway/commitstatus_test.go:140
            	Error:      	Received unexpected error:
            	            	rpc error: code = InvalidArgument desc = no identity provided
            	Test:       	TestCommitStatus/returns_transaction_status
    --- FAIL: TestCommitStatus/passes_channel_name_to_finder (0.00s)
        commitstatus_test.go:140: 
            	Error Trace:	/home/runner/work/fabric/fabric/internal/pkg/gateway/commitstatus_test.go:140
            	Error:      	Received unexpected error:
            	            	rpc error: code = InvalidArgument desc = no identity provided
            	Test:       	TestCommitStatus/passes_channel_name_to_finder
    --- FAIL: TestCommitStatus/passes_transaction_ID_to_finder (0.00s)
        commitstatus_test.go:140: 
            	Error Trace:	/home/runner/work/fabric/fabric/internal/pkg/gateway/commitstatus_test.go:140
            	Error:      	Received unexpected error:
            	            	rpc error: code = InvalidArgument desc = no identity provided
            	Test:       	TestCommitStatus/passes_transaction_ID_to_finder
    --- FAIL: TestCommitStatus/failed_policy_or_signature_check (0.00s)
        api_test.go:552: 
            	Error Trace:	/home/runner/work/fabric/fabric/internal/pkg/gateway/api_test.go:552
            	            				/home/runner/work/fabric/fabric/internal/pkg/gateway/commitstatus_test.go:135
            	Error:      	Error "rpc error: code = InvalidArgument desc = no identity provided" does not contain "POLICY_ERROR"
            	Test:       	TestCommitStatus/failed_policy_or_signature_check
            	Messages:   	error string
    --- FAIL: TestCommitStatus/passes_channel_name_to_policy_checker (0.00s)
        commitstatus_test.go:140: 
            	Error Trace:	/home/runner/work/fabric/fabric/internal/pkg/gateway/commitstatus_test.go:140
            	Error:      	Received unexpected error:
            	            	rpc error: code = InvalidArgument desc = no identity provided
            	Test:       	TestCommitStatus/passes_channel_name_to_policy_checker
    --- FAIL: TestCommitStatus/context_timeout (0.00s)
        api_test.go:552: 
            	Error Trace:	/home/runner/work/fabric/fabric/internal/pkg/gateway/api_test.go:552
            	            				/home/runner/work/fabric/fabric/internal/pkg/gateway/commitstatus_test.go:135
            	Error:      	Error "rpc error: code = InvalidArgument desc = no identity provided" does not contain "context deadline exceeded"
            	Test:       	TestCommitStatus/context_timeout
            	Messages:   	error string
    --- FAIL: TestCommitStatus/context_canceled (0.00s)
        api_test.go:552: 
            	Error Trace:	/home/runner/work/fabric/fabric/internal/pkg/gateway/api_test.go:552
            	            				/home/runner/work/fabric/fabric/internal/pkg/gateway/commitstatus_test.go:135
            	Error:      	Error "rpc error: code = InvalidArgument desc = no identity provided" does not contain "context canceled"
            	Test:       	TestCommitStatus/context_canceled
            	Messages:   	error string

@yeasy I think you also need to update the tests to adjust to your changes.

Fixed now.

Checking with goimports
The following files contain goimports errors
internal/pkg/gateway/commitstatus_test.go
make: *** [Makefile:182: linter] Error 1
The goimports command 'goimports -l -w' must be run for these files
Error: Process completed with exit code 2.

thanks, almost there, a little nit, please make sure to also pass basic checks.

@C0rWin
Copy link
Contributor

C0rWin commented Jan 31, 2024

@yeasy hey, do you have any ETA whenever you will be able to finalize your PR?

The patchset adds validation to the request before using it.

This can help protect from mal-formed request.

Change-Id: Ic6a7a65d6da289d84fe82c3f6e048e396b1f1a0e
Signed-off-by: Baohua Yang <yangbaohua@gmail.com>
Signed-off-by: Baohua Yang <baohua.yang@oracle.com>
@yeasy
Copy link
Member Author

yeasy commented Feb 1, 2024

commitstatus_test

Done! Let's see how it works.

@denyeart denyeart merged commit 74cece9 into hyperledger:main Feb 8, 2024
14 checks passed
@yeasy yeasy deleted the validate_request branch February 10, 2024 04:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants