kandi X-RAY | devnull Summary
kandi X-RAY | devnull Summary
devnull
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of devnull
devnull Key Features
devnull Examples and Code Snippets
Community Discussions
Trending Discussions on devnull
QUESTION
I am developing a simple blog engine in go using only the standard libraries (and the mysql driver 😁)
For the admin I am using Basic HTTP Auth
...ANSWER
Answered 2022-Apr-15 at 12:50When it comes down to storing credentials on a server or other runtime environment, you are somehow between the devil and the deep blue sea. There is no real good solution which is likewise usable.
Start asking yourself, what your threat model is.
- A: Secrets being persisted in version control, shared with others, or even worse, made public on GitHub etc.
- B: Secrets being exposed to unprivileged co-users of the runtime environment
- C: Secrets being exposed to privileged users of the runtime environment (including an attacker who compromised the system and was able to get privileged user rights).
Based on the threats defined, you can start assessing potential solutions to store and inject secrets. This will of course depend on your environment (e.g. OS, cloud provider, Kubernetes/Docker, etc.). In the following I will assume Linux as OS.
Pass in as parameter:
Would mitigate threat A, but not B and C. Command line arguments can be revealed even by unprivileged users e.g. by ps -eo args
Store in config file: Would mitigate threat B, given that file permissions are set correctly. With regard to A, there is still a risk that the config file is unintendedly added to the version control. Does not mitigate threat C.
If you would use e.g. json format for the config file, this could be implemented easily with the Golang standard lib.
Store in environment variables:
Would mitigate threats A and B, but not C. Privileged users can access the environment variables via /proc//environ
. Also the question remains how you will set the environment variables in the runtime environment. If you are using a CI/CD pipeline to deploy your service, this pipeline could be used to inject the environment variables during deployment. Usually, the CI/CD engine come with some kind of variable store for secrets.
Drawback of this approach is that the environment variables will be ephemeral, so after a reboot of the runtime environment you would need to redeploy via the CI/CD pipeline or you need to ensure persistence of the secrets in the runtime environment, e.g. in a startup script.
Environment variables can be read easily with os.Getenv()
or os.LookupEnv()
from the standard lib.
Enter manually on start time: Would mitigate A and B, but privileged users would still be able to read the secrets from memory. Upon reboot of the runtime environment, the service will not be available until an operator enters the secrets manually. So this approach would probably be considered as impractical in many use cases.
Further considerations:
Storing secrets in a database as suggested by brianmac shifts the question to "Where to store my db credentials?"
Combining secret encryption with any of the solutions described above will require that the decryption key is made available to the service in the runtime environment. So you either need a TPM-based solution or you are faced with the question, where to store this key.
"Secrets as a Service" solutions like Hashicorp Vault, Azure Key Vault, AWS Secrets Manager etc. will probably be oversized in your scenarion. They provide centralized storage and management of secrets. Applications/services can retrieve secrets from this solution via a defined API.
This, however, requires authentication and authorization of the service requesting a secret. So we are back at the question how to store another secret for the service in there runtime environment.
Cloud providers try to overcome this by assigning the runtime environment an identity and authorizing this identity to access other cloud resources including the "Secret as a Service" solution. Usually only the designated runtime environment will be able to retrieve the credentials of the identity. However, nothing can prevent an privileged user who has access the runtime environment from using the identity to access the secrets.
Bottom line is that it is hard to impossible to store secrets in a way that a privileged user or someone who compromised the system will not be able to get access.
If you accept this as the residual risk, storing the secrets in environment variables is a good approach as it can avoid persisting secrets. It is also platform agnostic and thus can be used with any runtime environment, cloud provider etc. It can also be supported by a variety of automation and deployment tools.
QUESTION
my question is a bit tricky here, in fact i'm trying to identify the ROLE of a word in a given sentence, i manage to get something using nltk, the problem is that it's telling me what the word is, what i'm searching for is it's job. For example God Loves Apples would not return God as a subject in this given sentence. in fact here it would return God as a NNP, which is not what i'm looking for. So im looking for getting as the dict key the role of the given word in it's string (looking for god as subject not god as NNP)
...ANSWER
Answered 2022-Mar-29 at 12:19You could use dependency parsing. NLTK is not ideal for this task, but there are alternatives like CoreNLP or SpaCy. Both can be tested online (here and here). The dependency tree will tell you that in God loves apples.
, the token God
is connected to the main verb with the nsubj
relation, i.e., nominal subject.
I usually go for SpaCy:
QUESTION
For sake of this question, I have a hello world python script called script.py
.
ANSWER
Answered 2022-Feb-23 at 16:09Don't you need an arm
image as suggested by the documentation:
Finally, depending on your project, the language that you use may have good support for cross-compilation. In that case, multi-stage builds in Dockerfiles can be effectively used to build binaries for the platform specified with --platform using the native architecture of the build node. A list of build arguments like BUILDPLATFORM and TARGETPLATFORM is available automatically inside your Dockerfile and can be leveraged by the processes running as part of your build.
QUESTION
I have been successfully building an image for many days now. I add all of my custom files to GitLab. I have not knowingly made changes to my build environment. I am now getting errors can can not build my image. Can anyone understand what this error is telling me? I have tried looking it up but nothing seems to work.
...ANSWER
Answered 2022-Feb-15 at 20:00If you get an error similar to this delete your build folder. Then recreate it. For NXP devices they give you the command
QUESTION
for a university project I am testing the log4j vulnerability. To do this, I use a python server that connects to the java client by creating a reverse shell. Everything works except the output to server which is not displayed correctly. Specifically, the server shows the output of two previous inputs and I'm not understanding why. I'm new to python and java programming so I'm a little confused.
Initial project: https://github.com/KleekEthicalHacking/log4j-exploit I made some changes and added a python socket to handle the reverse shell.
PS: with netcat it seems to work fine but command with some space non work (ex: cd ..
not work)
For run this project i use kali linux (python server) and ubuntu (java webapp). This code does not yet manage clients with windows os
poc.py + exploit class:
...ANSWER
Answered 2022-Feb-11 at 11:36Now works. I added time.sleep(0.2)
after each sendall in rce.py
QUESTION
I am working on yocto,dunfell, am trying to build .hddimg image for a genericx86-64 machine. I inherit image-live
, add hhdimg
to IMAGE_FSTYPES
and everything works fine with iso
, wic
and ... But when I add hddimg
I get this error:
ANSWER
Answered 2022-Jan-19 at 12:28Your rootfs for test-image
is larger than 4GB, which is the maximum filesystem size for FAT
partitions (the default used by the .hddimg
image type).
The error already contains two solutions:
- Reduce the image size, by removing packages
- Use the
wic
format (vmdk
andvdi
are for virtual machine engines)
To use the wic
format, simply add wic
to IMAGE_FSTYPES
and Yocto will build a .wic
image and place it in the deploy/images
directory. You can flash this to your disk using dd
or bmaptool
, and boot it.
These images are built from a template specified by WKS_FILE
, which defaults to genericx86.wks.in
for the the genericx86-64
machine. This default template creates a partition table and installs an EFI bootloader (Grub).
If you'd like to manually generate the wic
images or modify the templates, check out the documentation for Creating Partitioned Images Using Wic.
QUESTION
I know my post count looks suspicious but in my six years of coding I always found an answer by doing some research, this issue though has got me stumped so here goes my first post.
The problem I am facing is simple, I am using python to code a genetic algorithm for Hanabi game, while in other projects I used to print out some info normally so I can debug or ensure results are what expect them to be, in this project and for some very odd reason, whenever I use print() it does not produce an output in most cases, it does produce an output only if it is called from the main function, I will paste my code and result below:
...ANSWER
Answered 2022-Jan-11 at 20:59 with open(os.devnull, 'w') as devnull:
with contextlib.redirect_stdout(devnull):
result=run(25,num_players,chromosome)
print("chromosome",chromosome,"fitness",result)
QUESTION
I 've been reading almost all the posts related to this topic but I can´t find a solution!!!. My folder path is : C:\Users\User\Desktop\Data Analytics Arg\py_inst
Inside the folder I created a virtual env., I added the chromedriver.exe and my script as it can be seen in the image:
this is my script:
...ANSWER
Answered 2021-Dec-12 at 20:45This error message...
QUESTION
I have everything sorted out with this little program of mine, however after I have inserted actual data i will be using into the dictionary, the button.setEnable(False) stopped working. Any ideas why?
code:
...ANSWER
Answered 2021-Dec-06 at 16:13As correctly pointed out by @musicamante in the comments, I have left a line of code under
QUESTION
I want to do active (online) learning of a statistical model.
This means that I have an initial train dataset (x-y pairs) which is known at compile time.
However, by the active nature (online), more data comes at runtime, from a 3rd party program (a cpp simulation program).
I am doing this inside python using GPytorch
, and I am calling the 3rd party program via the subprocess
python module.
My problem is of programming type and not GPytorch or statistical type, thus my question here.
The workflow is: python dictates at which input parameters to run the .cpp, create a new folder named based on the params, enter the folder, run the .cpp, collect data which appeared in the folder, update the statistical model, python dictates at which input params to run the .cpp, create a new folder named based on the params, enter that folder, run the .cpp, collect data which appeared in that folder, update the statistical model ... (for, say, 100 times).
Inside a WSL1 terminal, I usually run the .cpp code using: $ mpirun -n 1 smilei namelist.py
, where this command is run inside a folder which contains both the executable smilei
but also the .py called namelist.py
The python workflow returns exit code 0 (and the necessary data) at the first iteration of my active learning loop, but fails and returns exit code 1 at the second iteration. It basically does its job for the first iteration, but fails for the 2nd one.
I tried with subprocess.run()
and with os.system()
(see the code below with all my trials preceeded by comments) where inside the parantheses I type the command I usually run inside a BASH WindowsSubsytemForLinux1 terminal to run the 3rd part cpp program.
I cannot debug why it fails for the second time.
I tried to print out the stdout
and the stderr
of the subprocess, they both return empty lines when queried, there are no such things it appears (no stdout and no stderror), for the second iteration of the active learning loop.
I know the code below might look complex, but it's not. It just follows the workflow I presented above.
...ANSWER
Answered 2021-Oct-29 at 10:41Two options I can think of
use try: except subprocess.CalledProcessError as e:print(e)
around the subprocess call. That will give you the error. The other option would be to print out the cmd and run it on the command line to see any errors. It could be that second time the code is executed there is a variable missing.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install devnull
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page