SHARE
TWEET
first hurdles
a guest
Jan 31st, 2016
8
Never
- 02:52:48 n-tech https://github.com/infinity-next/infinity-next/blob/master/app/FileStorage.php
- 02:52:50 n-tech jesus christ.
- 02:52:52 n-tech So bcause of how the Laravel framework works, to get the attachments inside a view
- 02:52:54 n-tech I just go:
- 02:52:56 n-tech @foreach ($post->attachments as $attachment)
- 02:53:00 n-tech the ->hash on $storage
- 02:53:07 n-tech {{$attachment->storage->hash}}
- 02:53:08 __uguu__ probably a bad way to do it
- 02:53:23 n-tech yeah that's my thought. It has to do a query per post. It's ineffecient.
- 02:53:37 __uguu__ at this point you want to get access via sql
- 02:54:06 * __uguu__ looks into it
- 02:54:26 __uguu__ what you want to do is...?
- 02:54:53 __uguu__ what are you trying to get done?
- 02:55:14 n-tech The hash is what's used to get the file's location.
- 02:55:25 n-tech /board/hash/filename.jpg
- 02:55:48 n-tech the board is irrelevant, just a part of the route. the filename is optional and it determines what it's called on download.
- 02:55:58 n-tech The point is to generate this string:
- 02:56:15 n-tech <img class="attachment-img" src="{!! url("{$board->uri}/file/{$attachment->storage->hash}/{$attachment->filename}") !!}" alt="{{ $attachment->filename }}" />
- 02:56:48 n-tech The getFile controller method is what distributes the content with the specified filename.
- 02:57:52 __uguu__ okay so given a post you want every hash of the attachment uploaded with that post?
- 02:58:46 n-tech The hash is derived from the upload and is used to prevent dulicate files on the harddrive and to deal with hash banning.
- 02:58:56 n-tech The MD5 is now the identifier for the system to pull the file from the request.
- 02:59:04 n-tech They are stored on the harddrive as their MD5 for a filename.
- 02:59:07 __uguu__ md5 collides
- 02:59:13 __uguu__ you really should use sha256
- 02:59:15 __uguu__ or sha1
- 02:59:22 n-tech There is approximately a 1x2^128 chance of that happening.
- 02:59:28 __uguu__ except that's not true
- 02:59:40 __uguu__ md5 is a borked hash algorithm
- 03:00:05 __uguu__ i.e. append nul to a file
- 03:00:10 __uguu__ still has the same md5
- 03:00:38 __uguu__ which is a collision
- 03:00:40 n-tech how is that not desirable when trying to prevent duplicates
- 03:00:53 __uguu__ my point is that md5 is pretty borked
- 03:01:02 __uguu__ <-- works with crypto
- [...]
- 07:39:03 ~copypaste reply_to is definitely flawed
- 07:39:09 ~copypaste you need something like TB's cite_posts table
- 07:39:13 ~copypaste it's hard to do but works very, very well
- 07:39:29 ~copypaste erm, it's just called ``cites`` actually.
- 07:40:00 ~copypaste DESC cites -> http://pastie.org/10183422
- 07:40:22 ~copypaste also
- 07:40:33 ~copypaste __uguu__: no, I recommended MD5 because that's what 4chan uses.
- 07:40:41 ~copypaste Who cares if a NUL byte changes the file?
- 07:40:47 ~copypaste Not me. That's a duplicate, feature not a bug.
- 07:40:58 ~copypaste erm, doesn't change the hash*
- 07:41:06 ~copypaste 4chan API expects md5. MD5 is best for this.
- 07:41:41 ~copypaste I understand you work in crypto. This isn't crypto, not really. There's no secret to be leaked.
RAW Paste Data
