Sando's Blog

Weekly Summary #8

Sando
Published: 07/15/2019

Hello everyone! 

"""

What did you do?

In this week i was working on the deployment of travis for the implementation of continuous integration in the project, some problems were fixed in the initial file of travis.

What are you going to do?

I will finish with the deployment of travis and will continue to perform tests and modifications suggested  to the project code

What problems did you have?

So far I could see Travis CI in a great tool for the development of the code, but so far the tests I can not run on their platform the same as in linux and windows, the problem is that the tests require a initial authorization that generates a valid access ticket with 12 hours of duration once obtained is saved in cache folder, with this you can run clients of web services, and each test with this authorization performs processes within the servers such as the generation of invoices, consultations, etc.
But for this AT to be generated, it needs to go through a process to give it the proper format for the initial web service to accept it, for which initially an RSA key and an x509 certificate are needed. which travis I can not get me to take to generate the AT.
It's probably a security protection issue in Travis.

"""

Regards and Good Week!

View Blog Post

Pyca / cryptography and some other things

Sando
Published: 07/08/2019

Hi everyone!

"""

In the last two weeks it was decided to change m2crypto by pyca/crytography, well all very nice but I knew about cryptography ... little and nothing.  I had read the code and more or less wise how it work. I was going to be a challenge quite high since the module in which I had to work is the backbone of the project (wsaa.py) which gives the functionality to the clients of the AFIP web services.
Well, I thought, - where we started now ... and I remembered a set of letters, RTFM, then I went directly to Eric Holscher's documentation page "Read the Docs" and found the doc of pyca/cryptography.
I read in the first example:

from cryptography.fernet import Fernet

And, the mere fact that this module has this name I like since it represents a delicious drink of common consumption in Argentina accompanied by a known soda.
There were four medodos that had to be changed and for this the "hazmat" module was used.
I had a sign at the entrance that suggested: enter at your own risk and that there could be dinosaurs with laser weapons, I said: Wow! This is for me.
And so I started to develop the methods (I invite you to follow the issue # PyAr # 15),
for the first 3 It reached me with the documentation (and a lot of testing) which left for the last was the most important since it contains the tra (an xml) and it must be signed together with PKCS7 and the private key + the certificate.
But I did not find anything at first glance that would lead me to results so I used another one of the most solid tools, the Stack Overflow and I found a response that could help me .Then I could see that the pyca / cryptography arrives "Bindings" and the high level code ends, I would have to use a low level code to achieve it, , although it was well detailed there were parts that did not let me work the code, since the service of Afip requests the data in a special way in smime format and only the body. I continue looking for an answer then.
After a lot of sailing and it was already a Monday I had spent the week dedicated, I had to finish.
I went straight to the repo of cryptography in github and found a very interesting (and long) issue that dealt with the subject and at the end of this encounter a commit that I start to read and it appears as magic the low level function that I was missing to change from pkcs7 begin to the smime.p7m header, with which I could use part of the final code that had been developed for m2crypto, which was nothing more than to cut this header and return only the body of the message. Howerever, I liked that it happened in this way.

Tuesday meeting with the mentors

In this meeting important topics are touched on how the month in the project had been that things were missing and that another could be added.
And the list was as follows:

    Update requirements.txt
    Pass the .py files all to utf-8.
    Eliminate coding and shebang lines in the beginning.
    Delete the modules that are going to belong to another project.
    Remove py2exe from setup.py
    Eliminate the unnecessary command line code from the modules.

I start to do the above mentioned until I get to the encoding to utf-8 I remember the words of my mentor when he explained to me and showed me with the "file" command the type of format that most tex / x-python had, UTF-8, with end of line in crlf.
With this command he showed me a world that I did not have in mind.
He told me it's simple, open and save in utf-8 and that's it.
Ok, I thought, it's easy. Until now I could not get my text editor to encode a new file into pure utf8.
Everything is saved in us-ascii, which is fine is a subset of Unicode, I say good should be a problem of the editor. I have configured the default options : "UTF-8".
I save the files with "save with encoding utf8" shows me the file as utf8,
but when I run :

 file -i * .py

outcome: command, text / plain , us-ascii,

In this test I run from the platform windows 10 in the bash of git that I have installed.
In a virtual environment that I have linux mint I managed to change the project files to utf8 with the command

iconv -f   (encoding) -t utf-8 file.py > file_out.py

But there was one nsis.py that was in us_ascii and there seems to be gods that change it probe with an option that I found that it was to change directly to utf-16 and after changing it to utf8 and it worked, utf8 at the end I say I put the command file and I get utf-8 with bom, (.-Ufs that don't see good), I read many negative comments of the BOM markers with java compilers (and that would have to do with python? I do not know, but just in case ...). I have to keep looking, I think it could be a platform problem.

I install linux mint directly on the machine. Until now I had the linux mint and ubuntu platforms in Virtual Box (At another time I will comment on the problems that I had with Oracle's VirtualBox)
but there were no solutions still turning everything into us-ascii
although in properties appear in utf8.
And the other thing I saw is that the line ends are for different platforms:

Unix lf
Windows drlf
Mac dr

Change editor, find some plug in, make some script ... are possible solutions that hover in my head.
Summing up the project worked before and works now . Nevertheless, I could not say if for these questions at some point something could fail. I will continue investigating since it seems an interesting and delicate topic.
 
In that week I also started with the implementation of Continuous Integration with a first advance with Travis CI and the initial file in my .travis.yml repository with test lines to check functionality, without good initial results. In the built of it, I received alerts of "deprecation of Python 2". I suppose it must be for the master branch and that in one of the dependencies I could not find the request module.

In this week that begins, the challenge is to be able to start using travis efficiently and go completing the necessary.

"""

Thank you and Good Week!

View Blog Post

Weekly Summary #6

Sando
Published: 07/01/2019

Hi there, How are you?

"""

What did you do last week


In the previous week  is they were doing tests on the modules.
As it was managing the possibility, by the instability in the installation in different platforms, it was decided with the mentors to change the dependency m2crypto by pyca/cryptography for the management and signature of the certificates. Substitution was completed in 3 methods: analyze certificate, create private key, create CSR (certificate signing request).


This week


It will end with the substitution m2crypto dependency by cryptography.
This week, i will begin with the implementation of continuous integration through travis CI in the project.


Comments


This week there are no problems to report.

"""

Regards and Good week!

View Blog Post

Weekly summary #5

Sando
Published: 06/24/2019

1013/5000

Hello everyone, how are you?

This is my weekly summary.


"" "
What did i do last week


This week multiplatform checks were made, the tests were continued trying to advance with the coverage.


This week


For this week the tests will continue and the operation of the m2crypto unit will be analyzed with the project


Comments


I had a warning running the tests with unittest.


ResourceWarning: unclosed ssl.SSLSocket 

Apparently the connection would not be closing during the execution of the tests and I found this,
because Python requests a design option, there is a warning about a connection that is not closed when running the tests:
https://github.com/kennethreitz/requests/issues/3912
A solution would be, suppress the warning as discussed in:
https://github.com/kennethreitz/requests/issues/1882
"" "
Regards and Good week!

View Blog Post

Weekly summary #4

Sando
Published: 06/17/2019

Hello, how you there! this is my weekly summary.


'' '
What did you do last week 


This week will be added to the dependencies configuration and the installation tests were run.
Minor arrangements were made in the imports
and the tests with unittest were improving.
   

 

This week

 

This week they will continue with the tests and starting to see how we will continue with the m2crypto dependency

 

Complication

 

I had problems with the installation of a dependence after running the installation tests, by the way it was installed through the dependency links, but then it was solved and the dependence on the installation is 100% functional.
'' '
Greetings and Good week!

View Blog Post