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

Prevent infinite loops #125

Merged
merged 5 commits into from
Oct 23, 2015
Merged

Prevent infinite loops #125

merged 5 commits into from
Oct 23, 2015

Conversation

andyroyle
Copy link
Collaborator

closes #124

This approach doesn't necessarily cope with nested loops, insofar as the __ITER variable will get redeclared in the lower scope.

This means that nested loops will run until the bottom loop hits the limit (not necessarily just the outer). We can guard separately against nested loops if we want to.

@matteofigus
Copy link
Member

This LGTM, but given it is a quite critical functionality, I would actually like if @jankowiakmaria and @pbazydlo could have a look too.

var _ = require('underscore');

var hashBuilder = require('../../utils/hash-builder');
var strings = require('../../resources');

var wrapLoops = function(code){
var CONST_MAX_ITERATIONS = 1e9; // should this be configurable?
Copy link
Member

Choose a reason for hiding this comment

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

Best would probably be to have a default (used during dev) and then get a configurable value on the registry level.

During publishing, CLI would ask the registry for packaging config and then use that value.
But at the moment, I don't care, this is enough.
Can you just remove the comment and perhaps move the value here? https://github.com/opentable/oc/blob/master/resources/settings.js

@andyroyle
Copy link
Collaborator Author

@matteofigus I've made those changes.

@jankowiakmaria how scary does it look?

@jankowiakmaria
Copy link
Collaborator

@andyroyle 😨

@andyroyle
Copy link
Collaborator Author

@matteofigus @jankowiakmaria tell you what, I'll pull the source of all the existing components and run it though the new packager and see if anything shakes loose

@matteofigus
Copy link
Member

Thanks, that's a good idea

@andyroyle
Copy link
Collaborator Author

I've run it against a selection of the components in our Preprod registry; Some I couldn't verify because the components don't link to the repo, but so far nothing I've seen worries me.

@andyroyle
Copy link
Collaborator Author

@matteofigus so I can't see any immediate problems that will be caused by this.

What do you think? Merge?

@matteofigus
Copy link
Member

Let me bump the patch for the other PR I just merged, then I would do a merge + minor for this, ok? give me a couple of mins.

matteofigus added a commit that referenced this pull request Oct 23, 2015
@matteofigus matteofigus merged commit 7beee74 into master Oct 23, 2015
@matteofigus matteofigus deleted the prevent-infinite-loops branch October 23, 2015 13:14
@matteofigus
Copy link
Member

Ok, published in 0.18.0

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.

Prevent component code from running infinite loops
3 participants