Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Security with Uploading CSV to update database

by dws (Chancellor)
on Aug 12, 2002 at 21:11 UTC ( [id://189632]=note: print w/replies, xml ) Need Help??


in reply to Security with Uploading CSV to update database

... a script which can be used to browse for a CSV, upload it, and execute a mySQL update using it's contents.

Could you expand on this a bit? As stated, I can read this two ways*. One is that the files being browsed for are on some local user's machine (e.g., using a file upload form), and that they're uploaded to a server where they're using to update a MySQL database. The other is that they're browsed from on the server, and are uploaded to a client workstation that has a MySQL database.

Assuming the former, you could use CGI.pm to handle a file upload, and then use TextCSV to pick it apart, loading it into MySQL. These are nicely separable problems.

The security problem you have to deal with is someone uploading bogus data. You can approach this either by restricting who can upload data (e.g., using the .htaccess method you propose), or by rigorous checking of the data before updating the database, or both.

*Learning to read requirements in conflicting ways is a useful skill for staying out of trouble.

  • Comment on Re: Security with Uploading CSV to update database

Replies are listed 'Best First'.
Re: Re: Security with Uploading CSV to update database
by jerrygarciuh (Curate) on Aug 12, 2002 at 21:26 UTC
    Thanks for the reply dws. Your assumption is correct. One of the handlers of the main database will be exporting the csv's and then using my script to upload the file and execute the update.

    Assuming that someone defeats the double password protection and attempts to upload bogus data, they will have to figure out how many fields there are (I do a check on the CSV data), an incorrect # of fields throws an error and a message like: "Error #553. Please contact Jerry Garciuh at Terrapin Station". What sort of more rigorous checking do you think should I employ?
    Thanks again
    jg
    _____________________________________________________
    Think a race on a horse on a ball with a fish! TG

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://189632]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2024-04-24 17:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found