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

PasswordProtectedFiles #5067

Merged
merged 35 commits into from
Sep 23, 2018
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
56418a3
PasswordProtectedFiles
dapocalypse Jul 28, 2018
ccea176
Added changelog for passwordprotectedfiles.
dapocalypse Jul 28, 2018
5ae29af
Password Protection Fixes
dapocalypse Jul 28, 2018
19ba053
Password Protection Fixes
dapocalypse Jul 28, 2018
093914b
fixes
dapocalypse Jul 28, 2018
d06f0a5
Makes password check a proc
dapocalypse Jul 29, 2018
b609ece
Proc Password Proctection Fixes
dapocalypse Jul 29, 2018
8af142c
Fixes typo acess
dapocalypse Jul 30, 2018
121103e
Allows to encrypt or decrypt files outside of file creation
dapocalypse Jul 30, 2018
2b4bd2b
Fix to encryp decrypt stuff
dapocalypse Jul 31, 2018
45fa2d4
Merge branch 'development' into development
dapocalypse Jul 31, 2018
f1da4d8
UGh, Fixes
dapocalypse Aug 1, 2018
fb816e4
Merge branch 'development' into development
dapocalypse Aug 1, 2018
3c00491
merge
dapocalypse Aug 1, 2018
49dc58a
Merge branch 'development' into development
dapocalypse Aug 3, 2018
7c83d5f
Fixes
dapocalypse Aug 3, 2018
8faefc1
Again?
dapocalypse Aug 3, 2018
28de024
forgot
dapocalypse Aug 3, 2018
43ec5f7
Merge branch 'development' into development
dapocalypse Aug 3, 2018
1ec8efc
Merge branch 'development' into development
dapocalypse Aug 3, 2018
8218fcb
Merge branch 'development' into development
dapocalypse Aug 4, 2018
17852bb
Merge branch 'development' into development
dapocalypse Aug 5, 2018
75e5820
Merge branch 'development' into development
dapocalypse Aug 5, 2018
af8cc38
Merge branch 'development' into development
dapocalypse Aug 7, 2018
f23c03d
Merge pull request #1 from Aurorastation/development
dapocalypse Aug 8, 2018
b867b90
Merge branch 'development' into development
dapocalypse Aug 11, 2018
d789693
Merge pull request #3 from Aurorastation/development
dapocalypse Aug 27, 2018
0fb1088
Yea, fixes shit
dapocalypse Aug 27, 2018
c5eac59
Merge pull request #4 from Aurorastation/development
dapocalypse Sep 2, 2018
65faf44
Fixes USB shit
dapocalypse Sep 2, 2018
5de0a28
Merge pull request #5 from Aurorastation/development
dapocalypse Sep 15, 2018
4d5c59f
Proably not the last commit
dapocalypse Sep 15, 2018
e26199a
Merge branch 'development' into development
dapocalypse Sep 16, 2018
38d917f
Merge branch 'development' into development
dapocalypse Sep 16, 2018
79ae330
Merge branch 'development' into development
skull132 Sep 23, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 14 additions & 1 deletion code/modules/modular_computers/file_system/computer_file.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ var/global/file_uid = 0
var/size = 1 // File size in GQ. Integers only!
var/obj/item/weapon/computer_hardware/hard_drive/holder // Holder that contains this file.
var/unsendable = 0 // Whether the file may be sent to someone via NTNet transfer or other means.
var/undeletable = 0 // Whether the file may be deleted. Setting to 1 prevents deletion/renaming/etc.
var/undeletable = 0 // Whether the file may be deleted. Setting to 1 prevents deletion/renaming/etc.
var/password = "" // Placeholder for password protected files.
var/uid // UID of this file

/datum/computer_file/New()
Expand All @@ -31,9 +32,21 @@ var/global/file_uid = 0
temp.unsendable = unsendable
temp.undeletable = undeletable
temp.size = size
temp.password = password
if(rename)
temp.filename = filename + "(Copy)"
else
temp.filename = filename
temp.filetype = filetype
return temp

/datum/computer_file/proc/can_access_file(var/mob/user, input_password = "")
if(!password)
return TRUE
else
if (!input_password)
input_password = sanitize(input(user, "Please enter a password to access file '[filename]':"))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think file '[filename]' is a bit redundant. What are you going to be accessing that isn't a file?

Copy link
Member

Choose a reason for hiding this comment

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

Imho its fine.

"Please enter a password to access"
Is what would be left and thats worse.

Maybe remove just the "file"
So its only:

Please enter a password to file '[filename]':

Copy link
Contributor

Choose a reason for hiding this comment

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

You're misunderstanding what I'm suggesting. Just removing the word 'file' is fine, so that it's Please enter a password to access 'foo':, or similar.

if (input_password == password)
return TRUE
else
return FALSE
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@

if(href_list["PRG_openfile"])
. = 1
open_file = href_list["PRG_openfile"]
var/obj/item/weapon/computer_hardware/hard_drive/HDD = computer.hard_drive
var/datum/computer_file/F = HDD.find_file_by_name(href_list["PRG_openfile"])
if (!F)
return
if (F.can_access_file(usr))
open_file = href_list["PRG_openfile"]
else
return
if(href_list["PRG_newtextfile"])
. = 1
var/newname = sanitize(input(usr, "Enter file name or leave blank to cancel:", "File rename"))
Expand Down Expand Up @@ -144,6 +151,29 @@
return 1
var/datum/computer_file/C = F.clone(0)
HDD.store_file(C)
if(href_list["PRG_encrypt"])
Copy link
Member

Choose a reason for hiding this comment

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

There are no checks present to see if the file is already encrypted.
That would allow a user to just hit the encrypt button again to set a password of their choosing.
You need to make sure that no password is set before encrypting the file

Copy link
Member

Choose a reason for hiding this comment

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

Checks are now present

. = 1
var/obj/item/weapon/computer_hardware/hard_drive/HDD = computer.hard_drive
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to check if HDD exists after this, and return if not. See line 135 or 146.

Copy link
Contributor

Choose a reason for hiding this comment

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

Skull's comment is now invalid, check is present

if (!HDD)
return
var/datum/computer_file/F = HDD.find_file_by_name(href_list["PRG_encrypt"])
if(!F || F.undeletable)
return
if(F.password)
return
dapocalypse marked this conversation as resolved.
Show resolved Hide resolved
F.password = sanitize(input(usr, "Enter an encryption key:", "Encrypt File"))
if(href_list["PRG_decrypt"])
. = 1
var/obj/item/weapon/computer_hardware/hard_drive/HDD = computer.hard_drive
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to check if HDD exists after this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Skull's comment is now invalid, check is present

if (!HDD)
return
var/datum/computer_file/F = HDD.find_file_by_name(href_list["PRG_encrypt"])
if(!F || F.undeletable)
return
if (F.can_access_file(usr))
F.password = ""
else
return
if(.)
SSnanoui.update_uis(NM)

Expand Down Expand Up @@ -185,7 +215,8 @@
"name" = F.filename,
"type" = F.filetype,
"size" = F.size,
"undeletable" = F.undeletable
"undeletable" = F.undeletable,
"encrypted" = !!F.password
)))
data["files"] = files
if(RHDD)
Expand All @@ -196,7 +227,8 @@
"name" = F.filename,
"type" = F.filetype,
"size" = F.size,
"undeletable" = F.undeletable
"undeletable" = F.undeletable,
"encrypted" = !!F.password
Copy link
Member

Choose a reason for hiding this comment

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

My fault.
This is for the USB files. It should have been added at the normal files.
Line 214-219 atm.

)))
data["usbfiles"] = usbfiles

Expand Down
37 changes: 37 additions & 0 deletions html/changelogs/dapocalypse-development.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
################################
# Example Changelog File
#
# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
#
# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
# When it is, any changes listed below will disappear.
#
# Valid Prefixes:
# bugfix
# wip (For works in progress)
# tweak
# soundadd
# sounddel
# rscadd (general adding of nice things)
# rscdel (general deleting of nice things)
# imageadd
# imagedel
# maptweak
# spellcheck (typo fixes)
# experiment
# balance
#################################

# Your name.
author: dapocalypse
Copy link
Contributor

Choose a reason for hiding this comment

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

DO NOT EDIT example.yml

Copy link
Member

Choose a reason for hiding this comment

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

It´s now a different file


# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
delete-after: True

# Any changes you've made. See valid prefix list above.
# INDENT WITH TWO SPACES. NOT TABS. SPACES.
# SCREW THIS UP AND IT WON'T WORK.
# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries.
# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog.
changes:
- rscadd: "Added a password protection system for files on modular computers."
5 changes: 5 additions & 0 deletions nano/templates/file_manager.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
{{:helper.link('DELETE', null, { "PRG_deletefile" : value.name }, value.undeletable ? 'disabled' : null)}}
{{:helper.link('RENAME', null, { "PRG_rename" : value.name }, value.undeletable ? 'disabled' : null)}}
{{:helper.link('CLONE', null, { "PRG_clone" : value.name }, value.undeletable ? 'disabled' : null)}}
{{if !value.encrypted}}
{{:helper.link('ENCRYPT', null, { "PRG_encrypt" : value.name }, (value.undeletable) ? 'disabled' : null)}}
{{else}}
{{:helper.link('DECRYPT', null, { "PRG_decrypt" : value.name }, (value.undeletable) ? 'disabled' : null)}}
{{/if}}
{{if data.usbconnected}}
{{:helper.link('EXPORT', null, { "PRG_copytousb" : value.name }, value.undeletable ? 'disabled' : null)}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why remove copying to USB drive? Please return this button.

{{/if}}
Expand Down