Skip to content

Add a validator for git / http sources - #137

Merged
segiddins merged 8 commits into
masterfrom
validate_spec_source
Jul 6, 2015
Merged

segiddins merged 8 commits into
masterfrom
validate_spec_source

Conversation

@orta

@orta orta commented Jun 4, 2015

Copy link
Copy Markdown
Member

This is some of the initial work around #136

I'm struggling with figuring out how to test this and whether it is safe. Assigning to @alloy to give a one over.

@orta
orta force-pushed the validate_spec_source branch from 04dcc4e to 3f27ae9 Compare June 4, 2015 21:39
Comment thread app/models/specification_wrapper.rb Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please, no subshells

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I couldn't think of a way to do the git lint without a subtle

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

system(‘curl’, ‘-IL’, @specification.source[:http], ‘-f’)

On Jun 4, 2015, at 5:44 PM, Orta notifications@github.com wrote:

In app/models/specification_wrapper.rb #137 (comment):

@@ -48,6 +49,20 @@ def validation_errors
results
end

  •  def validate_public_access
    
  •    return validate_http if @specification.source[:http]
    
  •    return validate_git if @specification.source[:git]
    
  •    true
    
  •  end
    
  •  def validate_http
    
  •    system("curl -IL #{ Shellwords.escape @specification.source[:http] } -f")
    
    I couldn't think of a way to do the git lint without a subtle

—
Reply to this email directly or view it on GitHub https://github.com/CocoaPods/trunk.cocoapods.org/pull/137/files#r31780251.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ahhh, ok

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

also, will want to redirect out & err to /dev/null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@segiddins

Copy link
Copy Markdown
Member

I can write up specs tomorrow, if you'd like.
I also want to know how @floere feels about doing even more stuff in a synchronous request.

@floere

floere commented Jun 5, 2015

Copy link
Copy Markdown
Member

@segiddins I can search my feelings ;) Not sure what problem it solves though. Help?

@segiddins

Copy link
Copy Markdown
Member

It makes sure pods in trunk are actually public ally accessible before allowing them to be pushed.

-Samuel E. Giddins

On Jun 5, 2015, at 9:04 AM, Florian R. Hanke notifications@github.com wrote:

@segiddins I can search my feelings ;) Not sure what problem it solves though. Help?

—
Reply to this email directly or view it on GitHub.

@floere

floere commented Jun 5, 2015

Copy link
Copy Markdown
Member

Ah thanks. Seems weird we haven't thought of this right when writing trunk.

The current code probably needs more error handling (or rather, status codes checking) and better - and more precise - info for the user so they can act appropriately.

Is it time yet for asynchronous processing of trunk pushes and reporting the running jobs on the command line?
Something like:

Checking if publicly available? ... Yes! (<repo url>)

@segiddins

Copy link
Copy Markdown
Member

The only reason I see to do that is the heroku timeout... It's ok to me if the actual push takes a bit from the users perspective.

-Samuel E. Giddins

On Jun 5, 2015, at 9:22 AM, Florian R. Hanke notifications@github.com wrote:

Ah thanks. Seems weird we haven't thought of this right when writing trunk.

The current code probably needs more error handling (or rather, status codes checking) and better - and more precise - info for the user so they can act appropriately.

Is it time yet for asynchronous processing of trunk pushes and reporting the running jobs on the command line?
Something like:

Checking if publicly available? ... Yes! ()
—
Reply to this email directly or view it on GitHub.

@floere

floere commented Jun 5, 2015

Copy link
Copy Markdown
Member

@segiddins We can set the Heroku timeout, should that be a problem.

@segiddins

Copy link
Copy Markdown
Member

@floere pretty sure it's bounded at 30 seconds

@floere

floere commented Jun 5, 2015

Copy link
Copy Markdown
Member

@alloy

alloy commented Jun 8, 2015

Copy link
Copy Markdown
Member

Seems weird we haven't thought of this right when writing trunk.

Trunk was really only interested in validating data it needed to be able to do its work, ensuring the rest of the podspec data is valid was upto the client.

@floere

floere commented Jun 8, 2015

Copy link
Copy Markdown
Member

@alloy Not saying it needs to do it – saying it's weird we haven't considered the case (at least I can't remember).

@floere

floere commented Jun 8, 2015

Copy link
Copy Markdown
Member

@segiddins @orta @alloy If the long-runny-ness of this becomes an issue, I see two solutions: background jobs/multi-request (the client periodically gets the latest state – good if we have many requests for trunk), or response streaming (updating the info the client has as we go – good if we don't have many requests for trunk). Putting this here so I don't forget.

@floere

floere commented Jun 8, 2015

Copy link
Copy Markdown
Member

@alloy Would you then prefer this verification be in the client?

@alloy

alloy commented Jun 8, 2015

Copy link
Copy Markdown
Member

Yeah I did consider it then, but left it to the client. Clearly that didn't turn out to be enough, probably because people push pods from private repos that their machines have access to at the time of validating :)

@floere

floere commented Jun 8, 2015

Copy link
Copy Markdown
Member

@alloy Ah yes… good point. I do remember that we discussed that trunk act as a guard for ok pods – and that the client only does checks to provide a responsive/comfortable UI. According to that line of thought, this code would need to be in trunk.

@alloy

alloy commented Jun 8, 2015

Copy link
Copy Markdown
Member

Yeah I think it’s fine to do this now in Trunk. I think it would just be good to keep these things to a minimum and not require an extra queue :)

@floere

floere commented Jun 8, 2015

Copy link
Copy Markdown
Member

@alloy We're both from the "do the minimum that works" school :)

@alloy

alloy commented Jun 8, 2015

Copy link
Copy Markdown
Member

@floere Yeah I know, it was a general statement ;)

@orta

orta commented Jun 11, 2015

Copy link
Copy Markdown
Member Author

Got a sense of what I think it would just be good to keep these things to a minimum and not require an extra queue means here?

What do I need to do to get this wrapped up?

@alloy

alloy commented Jun 11, 2015

Copy link
Copy Markdown
Member

I think it would be a good idea to add a timeout block around the call and log how long it took to perform, then you an fine tune it after it's in use.

I'd also urge you to not use a shell at all, but instead call open/spawn with an array of arguments. That way there can never be any illicit command execution.

@orta

orta commented Jul 1, 2015

Copy link
Copy Markdown
Member Author

Stuck the landing 10/10

OK, this PR now has everything that people have asked for 👍 - I'm still unsure how to test this, any guesses?

@alloy

alloy commented Jul 1, 2015

Copy link
Copy Markdown
Member

I’d just mock the call to Pod::HTTP.validate_url, expect the right argument, and return true/false, it’s implementation is already tested in the CP gem, and add an expectation for the call to system as well?

@orta
orta force-pushed the validate_spec_source branch 3 times, most recently from acd14ee to 8ab7a4e Compare July 1, 2015 16:28
@orta

orta commented Jul 1, 2015

Copy link
Copy Markdown
Member Author

Alright, this is 👍

Comment thread app/models/specification_wrapper.rb Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not take an &blk arg so you don't have to create explicit procs?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

not sure how to do that, and the proc worked for QIs earlier /shrug

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This would be a bit nicer yeah, not a show stopper, though. @segiddins can you add it, if you feel strongly about it?

Comment thread app/models/specification_wrapper.rb Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

shouldn't that be @specification.source[:tag] || @specification.source[:commit] || @specification.source[:branch] || 'HEAD' ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Given that it's trunk, it can only be :tag, and I'm validating it exists pod spec lint will have checked that the tag exists by this point.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Given that it's trunk, it can only be :tag, and I'm validating the repo exists - pod spec lint will have checked that the tag exists by this point.

@segiddins

Copy link
Copy Markdown
Member

@alloy can you give this a final look?

@alloy

alloy commented Jul 5, 2015

Copy link
Copy Markdown
Member

LGTM 👍

@segiddins

Copy link
Copy Markdown
Member

I'll make my few style changes, then merge tonight. Thanks @orta :)

@segiddins
segiddins force-pushed the validate_spec_source branch from 98deb0a to 95914cc Compare July 6, 2015 01:23
segiddins added a commit that referenced this pull request Jul 6, 2015
Add a validator for git / http sources
@segiddins
segiddins merged commit e065632 into master Jul 6, 2015
@segiddins
segiddins deleted the validate_spec_source branch July 6, 2015 01:28
@alloy

alloy commented Jul 6, 2015

Copy link
Copy Markdown
Member

Nice work, fellas 👍

@orta

orta commented Jul 6, 2015

Copy link
Copy Markdown
Member Author

Thanks sir

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.

5 participants