okx / exchain

⛓️ EVM & Wasm $ IBC-compatible, OKTC is a L1 blockchain network built on top of Cosmos SDK that aims for optimal interoperability and performance ✨
https://www.okx.com/oktc
Other
572 stars 182 forks source link

Add x/backend query params verification #293

Closed fpChan closed 4 years ago

fpChan commented 4 years ago

Summary of Bug

add x/backend query params verification

1. Describe

the invalid request should return after params verification.
the page and per-page params need verification in the following code.

type QueryMatchParams struct {
    Product string
    Start   int64
    End     int64
    Page    int
    PerPage int
}

// NewQueryMatchParams creates a new instance of QueryMatchParams
func NewQueryMatchParams(product string, start, end int64, page, perPage int) QueryMatchParams {
    if page == 0 && perPage == 0 {
        page = DefaultPage
        perPage = DefaultPerPage
    }
    return QueryMatchParams{
        Product: product,
        Start:   start,
        End:     end,
        Page:    page,
        PerPage: perPage,
    }
}

2. Impact

Invalid database request

3. Recover

None

Expected Result

the invalid request should return after params verification.

Version

Steps to Reproduce


For Admin Use

ilovers commented 4 years ago

fixed in opendex pr. commit: https://github.com/okex/okchain/pull/305/files#diff-98356b82e627197cec835b6b36876ae1