This module will provide more security for your user input forms.

The secure form module restricts a file upload, if there is a mismatch between the MIME type and extension of the file. It also provides an option to set the auto-complete property to off in form fields. A privileged user can manage (enable/disable) both these options from configuration section.

Drupal Version: 7.x
Project Sandbox Link: https://drupal.org/sandbox/drupaldevassyst/2134633
Checkout/Link: git clone --branch 7.x-1.x http://git.drupal.org/sandbox/Drupaldevassyst/2134633.git secure_form

Manual review of other projects:
https://drupal.org/comment/8214813#comment-8214813
https://drupal.org/comment/8255219#comment-8255219
https://drupal.org/comment/8258309#comment-8258309
https://drupal.org/comment/8258491#comment-8258491
https://drupal.org/comment/8259167#comment-8259167
https://drupal.org/comment/8262653#comment-8262653

Comments

drupaldev@assyst’s picture

Assigned: drupaldev@assyst » Unassigned
PA robot’s picture

Status: Needs review » Needs work

There are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxDrupaldevassyst213463...

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.

drupaldev@assyst’s picture

Status: Needs work » Needs review

Issues shown by PAReview are fixed now. Please review.

drupaldev@assyst’s picture

Issue summary: View changes

Git access link has been modified.

drupaldev@assyst’s picture

Issue summary: View changes
barthje’s picture

Status: Needs review » Needs work

For starters, I can't checkout your branch. It's asking me for your password.

drupaldev@assyst’s picture

Status: Needs work » Needs review

Git link has been updated, please try now.

drupaldev@assyst’s picture

Issue summary: View changes
drupaldev@assyst’s picture

Issue summary: View changes

Git repository path/settings has been updated.

drupaldev@assyst’s picture

Issue summary: View changes
xiukun.zhou’s picture

Status: Needs review » Needs work

Hi.
When you try catch error after, you can watchdog_exception in http://drupalcode.org/sandbox/Drupaldevassyst/2134633.git/blob/HEAD:/sec...

  catch (Exception $e) {
    // Capture any exception raised to be recorded in watchdog.
    watchdog_exception('secure_form', $e, $e->getMessage());
}

Why not use system_settings_form

Replace

/**
 * Form to manage module configurations.
 */
function secure_form_settings() {
  $form['check_file'] = array(
    '#type' => 'checkbox',
    '#title' => t('Turn on file checker'),
    '#description' => t('When enabled, it will restrict file upload, if there is a mismatch between file MIME type and extension.'),
    '#default_value' => variable_get('secure_form_check_file'),
    '#weight' => 0,
  );

  $form['form_autocomplete'] = array(
    '#type' => 'checkbox',
    '#title' => t('Turn off form autocomplete'),
    '#description' => t('When enabled, it will turn off the autocomplete property on all user input forms.'),
    '#default_value' => variable_get('secure_form_autocomplete_form'),
    '#weight' => 1,
  );

  $form['save'] = array(
    '#type' => 'submit',
    '#value' => 'Save',
    '#weight' => 2,
  );

  return $form;
}

/**
 * Submit handler for secure_form_settings form.
 */
function secure_form_settings_submit($form, &$form_state) {
  $check_file = $form_state['values']['check_file'];
  variable_set('secure_form_check_file', $check_file);
  $form_autocomplete = $form_state['values']['form_autocomplete'];
  variable_set('secure_form_autocomplete_form', $form_autocomplete);
}
/**
 * Form to manage module configurations.
 */
function secure_form_settings() {
  $form['secure_form_check_file'] = array(
    '#type' => 'checkbox',
    '#title' => t('Turn on file checker'),
    '#description' => t('When enabled, it will restrict file upload, if there is a mismatch between file MIME type and extension.'),
    '#default_value' => variable_get('secure_form_check_file'),
    '#weight' => 0,
  );

  $form['secure_form_autocomplete_form'] = array(
    '#type' => 'checkbox',
    '#title' => t('Turn off form autocomplete'),
    '#description' => t('When enabled, it will turn off the autocomplete property on all user input forms.'),
    '#default_value' => variable_get('secure_form_autocomplete_form'),
    '#weight' => 1,
  );


  return system_settings_form($form);
}

drupaldev@assyst’s picture

Status: Needs work » Needs review

Thanks xiukun.zhou. Updated the code based on your comment.

drupaldev@assyst’s picture

Issue summary: View changes
drupaldev@assyst’s picture

Issue tags: +PAreview: review bonus
candotri’s picture

I think that it looks fine. I see good explanation in the README, clear and seemingly compliant function headers, readable code, and logical functions. Good work!

Richard_Appnovation’s picture

Nice work! Your module is clean and tidy.

A recommendation is do a hook_requirement during INSTALL and RUNTIME to check if PHP functions provided by fileinfo extension exists.

There no major flaws found in the module.

Richard_Appnovation’s picture

Status: Needs review » Reviewed & tested by the community
klausi’s picture

Issue summary: View changes
Issue tags: -PAreview: review bonus

Removing review bonus tag, you have not done all manual reviews, you just posted the output of an automated review tool. Make sure to read through the source code of the other projects, as requested on the review bonus page.

klausi’s picture

The Git commits are not connected to your user account. You need to specify an email address. See http://drupal.org/node/1022156 and http://drupal.org/node/1051722

drupaldev@assyst’s picture

Thank you AgentAlpha. Install file has been updated with hook_requirements.

drupaldev@assyst’s picture

Thank you klausi for the details and sorry for wrong update. Will perform manual review and update the bonus tag as suggested.

Now git config has changed with email address.

drupaldev@assyst’s picture

Issue summary: View changes

Added one more link to manual review.

drupaldev@assyst’s picture

Issue summary: View changes

Added one more link to manual review.

drupaldev@assyst’s picture

Issue summary: View changes

Added one more link to manual review.

drupaldev@assyst’s picture

Issue summary: View changes

Added one more link to manual review of other projects.

drupaldev@assyst’s picture

Issue summary: View changes

Added one more link to manual review of other projects.

drupaldev@assyst’s picture

Issue tags: +PAreview: review bonus

PAReview: review bonus tag added, manually reviewed 6 projects.

klausi’s picture

Status: Reviewed & tested by the community » Fixed

manual review:

  1. I think you have a typo in your git mail address: Drupaldev@assyst . That's why the commit is still not associated with your account?
  2. I find the module name a bit misleading. The first feature is regarding file uploads, so a better name would be "upload_mime_check" or whatever. The second feature is not about security at all? Why would someone want to disable all autocomplete fields?
  3. secure_form_file_validate(): this should use drupal_unlink() instead of unlink().

Anyway, that are not critical application blockers, so ...

Thanks for your contribution, Drupaldev@assyst!

I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.

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.

Thanks to the dedicated reviewer(s) as well.

drupaldev@assyst’s picture

Thank you Klausi for taking the time to review the module and setting it to full status.

To answer your questions/comments:

  1. Git mail address has been corrected.
  2. We have used this option/feature in most of our projects based on client/stakeholder request, especially in non profit organization portals. As per their concern, with out this option it a security scan failure. We have a plan to include more such options/features in this module in future, so we gave a common name secure_form.
  3. Modified the secure_form_file_validate() as suggested.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.