This is simple example of angular js. How we can add records in db and can show through angular js
Project page :
https://www.drupal.org/sandbox/himmat1/2384845
Git :
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/Himmat1/2384845.git angular_js_example
cd angular_js_example
Manual reviews of other projects
none yet.
| Comment | File | Size | Author |
|---|---|---|---|
| #22 | angular_js_example.patch | 8.61 KB | pol |
Comments
Comment #1
himmatbhatia commentedComment #2
drummSee https://www.drupal.org/node/1011698 - this issue should be in the project applications queue.
Comment #3
PA robot commentedGit clone command for the sandbox is missing in the issue summary, please add it.
We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)
Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #4
himmatbhatia commentedI have added the git clone commands for this project.
Comment #5
himmatbhatia commentedComment #6
himmatbhatia commentedComment #7
himmatbhatia commentedComment #8
himmatbhatia commentedComment #9
himmatbhatia commentedComment #10
himmatbhatia commentedComment #11
PA robot commentedClosing due to lack of activity. If you are still working on this application, you should fix all known problems and then set the status to "Needs review". (See also the project application workflow).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #12
himmatbhatia commentedComment #13
urashima82 commentedThe code seems good, I've installed it, and it works well.
But even though this is just an example module, some good practices are not respected.
angular_js_example_help :
$output = t("This is simple example of angular js. How we can add records in db and can show through angular js.");angular_js_example_menu :
angularjs-form.tpl.php :
Regards.
Comment #14
urashima82 commentedangular_js_example_menu :
Add t() function to description and title menu items (in order to translate)Comment #15
urashima82 commentedangular_js_example_menu :
Add t() function to description and title menu items (in order to translate)Comment #16
himmatbhatia commentedComment #17
himmatbhatia commentedComment #18
pravin ajaaz commentedManual Review:
1. You should consider adding a description to the module page.
2. You have provided the access callback as "TRUE". So it can be accessible by an anonymous user too. Is that what you feel right?
3. You can use url() instead of $base_url
4. You have not filtered the $_POST data before inserting in DB. This might be a security issue
5. You can also feel free to create an issue in Examples Module to add this as a feature.
Comment #19
pravin ajaaz commentedComment #20
pravin ajaaz commentedYou have not filtered the $_POST data before inserting in DB. This might be a security issue.
Comment #21
klausiSaving $_POST data is not a problem by itself, since Drupal stores user provided data unaltered. "When handling data, the golden rule is to store exactly what the user typed. When a user edits a post they created earlier, the form should contain the same things as it did when they first submitted it. This means that conversions are performed when content is output, not when saved to the database" -- from https://www.drupal.org/node/28984
But we have 2 other related security problems here, can you name those? As part of our git admin training I'm assigning this to joachim so he can take a look. If he does not find anything within a week I'm going to post the vulnerability details.
Comment #22
polHello,
Thanks for your module, I was looking for an example too to try Angular JS.
My question is, why not using the module 'angularjs' as dependency ? It could load the angularjs lib properly instead of hardcoding the path to the js in the block content array ?
Anyway, I made a small patch to fix some stuff, I don't really know if it fixes the two security issues, I haven't seen them.
Comment #23
joachim commented> This means that conversions are performed when content is output, not when saved to the database
AFAICT, that's not happening. There are two places where data retrieved from the database is output with print json_encode() in page callbacks. I'm not a JS expert (and the messy indentation in the JS file makes it harder to read), but I don't think the JS that retrieves that data is doing any sanitizing of its own.
So while it's ok to put whatever the user gives you into the database verbatim, you need to sanitize it before you output it anywhere. All the fields from the query should be run through check_plain().
A few other things:
- $schema['books'] = array(
Prefix table names with your module name to avoid clashes.
- The indentation in the TPL file needs fixing as well as in the JS file.
Comment #24
himmatbhatia commentedHello
I have fixed most of things which stated above. Made changes according to above patch. And made table prefix with module name
Thanks
Comment #25
polHello,
Once again, why not using the module angularjs as dependency ?
Thanks for replying.
Comment #26
himmatbhatia commentedHello,
I this is the simple module. If we give angularjs as dependency then we have to install AngularJS Examples of their module. Also for enabling AngularJS Examples we need to need install Restws. So the conclusion is many more things need to install only for the example module. User will irritate.
Only for using one js file of angular.min.js have to install above much things if we give dependency to angularjs.
Thanks
Comment #27
polOk thanks!
Comment #28
himmatbhatia commentedHello,
I have also review and fixed the indentation and alignment problem by using the http://pareview.sh/.
Can any budy let me know what other step i have to take for this module to be published as full module
Thanks
Comment #29
himmatbhatia commentedComment #30
pravin ajaaz commentedIf you have made all the essential changes suggested. then change the status to "Needs Review" and also try to get some "Review Bonus" to speed up the process.
Comment #31
himmatbhatia commentedComment #32
pravin ajaaz commentedYou should do a minimum of three manual reviews of other projects inorder to add a review bonus tag. But you have mentioned only two reviews in the issue summary.
Please add one more review and add the review bonus tag.
Comment #33
himmatbhatia commentedComment #34
himmatbhatia commentedHello Pravin,
I have mentioned the other review also.Now it becomes at least three Now it can be go for -PAReview: review bonus
Thanks
Comment #35
himmatbhatia commentedComment #36
pravin ajaaz commented@himmatbhatia: Sorry. But the latest reviews you did were just pasting the automated reviews. Actually in order to get the review bonus, you have to do a manual review of other projects. Because PA robot already mentioned about the automated review result in all the applications. If you spent some time to review other projects manually others would do it back to you and your code would meet the standards.
Here is a template that you can use to make sure you cover all of the necessary points in your review:
https://groups.drupal.org/node/427683
Comment #37
klausiAnyone with the "access content" permission can save book data. I think this is a very bad example security-wise and not a realistic scenario, so you should use a proper content creator permission for that.
angular_js_example_form_data_save() bypasses the form API and directly saves data from $_POST. Security quiz: what is the name of that security vulnerability and why is it a problem?
Comment #38
pravin ajaaz commented@klausi: Form API will sanitize the text using check_plain() by default. If form API is not used, we have to apply check_plain() manually before inserting into db. Is that right?
Comment #39
himmatbhatia commentedHello
I have now created now the permission for the access and addition of book content. Also i have used the check_plain() before inserting in to the database. Is that ok now @klausi ?
Thanks
Comment #40
himmatbhatia commentedComment #41
himmatbhatia commentedComment #42
klausiNope, that is not right, XSS is not the problem here. As I said: "When handling data, the golden rule is to store exactly what the user typed. When a user edits a post they created earlier, the form should contain the same things as it did when they first submitted it. This means that conversions are performed when content is output, not when saved to the database" -- from https://www.drupal.org/node/28984
So the check_plain()s in angular_js_example_form_data_save() are wrong and should be removed.
There is a different vulnerability here, keep on searching.
Comment #43
himmatbhatia commentedComment #44
himmatbhatia commentedHello klausi,
i have removed check_plain()s from angular_js_example_form_data_save() . And performed when the content is output.I mean before outputing when we fetch.
Thanks
Comment #45
himmatbhatia commentedComment #46
klausiCool, and there is still a security vulnerability present. Leaving this assigned to joachim so that he can take a look if he has time. Otherwise I will post the vulnerability details in one week.
Comment #47
pravin ajaaz commented@klausi: Instead of filtering using check_plain() before insetring into DB, should we use that in template (angularjs-form.tpl.php) before listing all the books created?
@himmatbhatia: Please don't do any changes until kalusi approves it.
Comment #48
himmatbhatia commentedComment #49
himmatbhatia commentedComment #50
himmatbhatia commentedComment #51
himmatbhatia commentedHello klausi/joachim
Can you give me furthur update on this security vulnerability. I am waiting for your vulnerability details.
Thanks
Comment #52
klausiangular_js_example_form_data_save(): this menu callback is vulnerable to CSRF exploits. Data from POST requests that is written to the database needs to be CSRF protected with the form API or CSRF tokens, see http://epiqo.com/en/all-your-pants-are-danger-csrf-explained or https://docs.acquia.com/articles/protecting-your-drupal-module-against-c...
Comment #53
klausiAnd please don't remove the security tag, we keep that for statistics and to show examples of security problems.
Comment #54
himmatbhatia commentedHello klausi,
I have done some fixes for csrf in the module as well as in js file. I have fixed it by the way of angular js provide the security system.
Is that you want to tell me.
can you review now
Thanks
Comment #55
PA robot commentedProject 1: https://www.drupal.org/node/2384917
Project 2: https://www.drupal.org/node/2503523
As successful completion of the project application process results in the applicant being granted the 'Create Full Projects' permission, there is no need to take multiple applications through the process. Once the first application has been successfully approved, then the applicant can promote other projects without review. Because of this, posting multiple applications is not necessary, and results in additional workload for reviewers ... which in turn results in longer wait times for everyone in the queue. With this in mind, your secondary applications have been marked as 'closed(duplicate)', with only one application left open (chosen at random).
If you prefer that we proceed through this review process with a different application than the one which was left open, then feel free to close the 'open' application as a duplicate, and re-open one of the project applications which had been closed.
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #56
klausiLeaving this application open instead of the other one.
angular_js_example_form_data_save() does not check the CSRF token? So the CSRF vulnerability is still there.
Comment #57
himmatbhatia commentedHello klausi
angular_js_example_form_data_save now check the CSRF token and after proper validating that token it will store data.
Please have a look now.
Thanks
Comment #58
himmatbhatia commentedHello Klausi,
Can you review it and give me the updates. And what now i have to do after this for making it a full project.
Thanks
Comment #59
himmatbhatia commentedComment #60
himmatbhatia commentedHello klausi,
Can you review now and feedback me
Thanks
Comment #61
klausiRemoving review bonus tag, you have not done any manual review, you just posted the output of an automated review tool or requested the addition of hook_help(). Make sure to read through the source code of the other projects, as requested on the review bonus page.
Comment #62
manish.upadhyay commentedHi,
Please fix below errors:
1. angular_js_example.module : line number -96 : Array closing indentation error, expected 6 spaces but found 4.
2. Try to use only hooks in module file and any other function should be kept in separate file, it is just my recommendation not an error.
3. It is very specific to a previous version of angular js, please mention that in ReadME.txt.
Thanks,
Comment #63
klausi@manish.upadhyay: those are good tips for improvements, but surely not application blockers. Anything else that you found or should this be RTBC instead?
Comment #64
himmatbhatia commented@klausi
Please let me know when the module will be available on the drupal community. Or is any thing more i have to do so for in this module.
Let me know what other enhancement do we need.
Thanks
Himmat
Comment #65
prashantmbhavsar commentedThe module looks good, it works well.
Some observations/suggestion:
1. You should have to check on db_insert query fails or success. You can use below try catch code to do that:
try {
db_insert('...')->execute();
// No exception thrown; PDO thinks the record was inserted correctly.
}
catch (PDOException $e) {
// Query failed; redirect or show user custom message by using $e->getMessage()
}
2. bookprice and authorid fields should be integer instead of varchar
3. Check for blank fields while inserting to database (Validation on form)
Comment #66
joshideas commentedThen it is ready for approval, I can't see any other (blocking) issue here.
Comment #67
joshideas commentedComment #68
kattekrab commented@himmatbhatia - You can now promote this to a full project yourself.
Comment #69
himmatbhatia commented@kattekrab i have promoted this to a full project. But still its not available to download as other contributed modules we can download.
Any thing i am missing.
Comment #70
himmatbhatia commented@kattekrab Also on this module getting the message ( This project is not covered by Drupal’s security advisory policy).
What needs to be done to fix this. Can you help me.
Comment #71
kattekrab commented@himmatbhatia - in order to make your project available for download, you need to tag a release. I'm not sure how to do that, but there is documentation on drupal.org that will guide you how.
As for security coverage, you need to complete the review process here, and request security coverage.
It has been marked RTBC, so that's a good sign.
You should conduct at least 3 manual reviews of other projects in order to get the review bonus, that means your project will get reviewed by one of the Git admins.
Comment #72
avpadernoThank you for your contribution!
I updated your account so you can opt into security advisory coverage now.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
Thank the dedicated reviewer(s) as well.
Comment #73
himmatbhatia commentedThanks for every one helped me. Its launched now!!!!.
Comment #74
klausiAssigning credits.