Git Product home page Git Product logo

Comments (11)

aalmanza1998 avatar aalmanza1998 commented on July 29, 2024 1

They are generated using:
random_str = base64.urlsafe_b64encode(os.urandom(9)).decode('ascii')

from ngshare.

lxylxy123456 avatar lxylxy123456 commented on July 29, 2024

@aalmanza1998 can you remind me of how random strings look like?

from ngshare.

Lawrence37 avatar Lawrence37 commented on July 29, 2024

Is the random string really necessary in ngshare? It seems like it's only used to prevent unauthorized access to submissions. ngshare should be able to do that without a random string.

from ngshare.

lxylxy123456 avatar lxylxy123456 commented on July 29, 2024

We may want to prevent the case that a student submits two requests at the same time and accidentally generates two submissions with the same timestamp (Though it is very likely, I think there is no guarantee that the timestamps will be always different). So adding a random string can decrease this possibility of collision further.

from ngshare.

Lawrence37 avatar Lawrence37 commented on July 29, 2024

The timestamp has microsecond precision, so it's extremely unlikely that there will be duplicate timestamps. If we are really so concerned about such a rare event, we should generate a unique submission ID for each submission and use that instead of a random number.

from ngshare.

aalmanza1998 avatar aalmanza1998 commented on July 29, 2024

What would that ID consist of?

from ngshare.

lxylxy123456 avatar lxylxy123456 commented on July 29, 2024

uuid is a good choice

from ngshare.

lxylxy123456 avatar lxylxy123456 commented on July 29, 2024

From python help:

# make a random UUID
>>> uuid.uuid4()    # doctest: +SKIP
UUID('16fd2706-8baf-433b-82eb-8c7fada847da')

It seems to be almost collision-free. e.g. https://softwareengineering.stackexchange.com/a/130298

I think you can first continue working with the current random string. Changing this should be easy in backend and require no work in frontend.

from ngshare.

aalmanza1998 avatar aalmanza1998 commented on July 29, 2024

@Lawrence37 are you having issues with notebook_hash or make_unique_key or are you just looking at alternatives?

from ngshare.

Lawrence37 avatar Lawrence37 commented on July 29, 2024

Part of it is that retrieved submissions don't store the random string, and consequently, releasing feedback lacks the required random string. It would be great if we don't introduce a way to store the string in the filesystem so that we can maintain maximum compatibility with the current exchange.

The other reason is to avoid unnecessary clutter in the API.

from ngshare.

lxylxy123456 avatar lxylxy123456 commented on July 29, 2024

I kind of understand. Can you demonstrate it more tomorrow during / after the meeting? If reasonable I think we can remove random str from API.

from ngshare.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.