Skip to content
This repository was archived by the owner on May 10, 2018. It is now read-only.

Generalized the find_build service's parameters#254

Open
Aaron1011 wants to merge 8 commits intotravis-ci:masterfrom
Aaron1011:find_build
Open

Generalized the find_build service's parameters#254
Aaron1011 wants to merge 8 commits intotravis-ci:masterfrom
Aaron1011:find_build

Conversation

@Aaron1011
Copy link
Contributor

No description provided.

@Aaron1011 Aaron1011 closed this Sep 8, 2013
@Aaron1011 Aaron1011 reopened this Sep 8, 2013
@joshk
Copy link
Contributor

joshk commented Sep 8, 2013

we should probably whitelist params which are accepted, as this could become a DDOS vector by creating slow queries, and also potentially a security attack vector.

@sarahhodne
Copy link
Contributor

I think just params.slice would do, no need to raise an error if more params are passed (most, if not all, other services just ignore additional params).

@Aaron1011
Copy link
Contributor Author

@henrikhodne @joshk: Does this look good?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd use params.slice(ALLOWED_PARAMS) instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

That might have to be params.slice(*ALLOWED_PARAMS), now that I think about it.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 to slice

On 13/09/2013, at 12:03 AM, Henrik Hodne notifications@github.com wrote:

In lib/travis/services/find_build.rb:

@@ -30,7 +32,7 @@ def all_resources
end

     def result
  •      @result ||= scope(:build).find_by_id(params[:id])
    
  •      @result ||= scope(:build).where(params.select { |k| ALLOWED_PARAMS.include? k.to_sym } ).first
    
    That might have to be params.slice(*ALLOWED_PARAMS), now that I think about it.


Reply to this email directly or view it on GitHub.

@Aaron1011
Copy link
Contributor Author

@henrikhodne @joshk: Okay, fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

Are all those params currently used for the where search? Does it make sense to allow all these? Especially as the previous implementation was find_by_id?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@joshk: I need to add at least owner_id and pull_request_number for my other PR to cancel builds when a PR is closed. I don't think the others are necessary right now, so we could remove them.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you point me to the related PRs again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@joshk: Here it is. The parameters to cancel_build get passed along to find_build.

Copy link
Contributor

Choose a reason for hiding this comment

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

I can't see owner_id being used here, and although pull_request_number is needed, it feels like the interaction can be encapsulated a little better. I need to think about this a little. Will look at it more this week.

@Aaron1011
Copy link
Contributor Author

@joshk: Ping

1 similar comment
@Aaron1011
Copy link
Contributor Author

@joshk: Ping

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants