<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dhruvi Doshi on Medium]]></title>
        <description><![CDATA[Stories by Dhruvi Doshi on Medium]]></description>
        <link>https://medium.com/@dhruvidoshi?source=rss-cb9af9aa224b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Ry1Q4UXH6Kt7XBapL6AhBw.png</url>
            <title>Stories by Dhruvi Doshi on Medium</title>
            <link>https://medium.com/@dhruvidoshi?source=rss-cb9af9aa224b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 24 May 2026 04:28:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dhruvidoshi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Survey6 — Sprint2 @ GSOC’23]]></title>
            <link>https://medium.com/scorelab/survey6-sprint2-gsoc23-b5f5ef188a1d?source=rss-cb9af9aa224b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b5f5ef188a1d</guid>
            <category><![CDATA[scorelab]]></category>
            <category><![CDATA[gsoc2023]]></category>
            <category><![CDATA[gsoc]]></category>
            <dc:creator><![CDATA[Dhruvi Doshi]]></dc:creator>
            <pubDate>Sun, 27 Aug 2023 10:38:16 GMT</pubDate>
            <atom:updated>2023-08-27T10:38:16.413Z</atom:updated>
            <content:encoded><![CDATA[<h3>Survey6 — Sprint2 @ GSOC’23</h3><p>Yet another year of Google Summer of Code, yay!</p><p>It gave me immense pleasure to take forward the project that I had started off in the previous sprint of GSOC’22.</p><h4>Survey6: In brief</h4><p>Survey6 is a geo-distributed grid application with C&amp;C Server as its center and the probes as the packet collection application for intercepting IPv6 traffic on linux.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/1*8DX7oD9fFWlagYiqFSlfjA.png" /></figure><h4>Work done in GSOC’2022</h4><p>Major parts of the C&amp;C Server and some functionalities of the probe was done in the previous year.</p><ol><li>Writing protobuf definitions</li><li>Setting up server database</li><li>writing connection and disconnection endpoints</li><li>data capture mechanism at probe</li><li>CLI for server</li><li>packaging for server</li></ol><h4>Work done in GSOC’2023</h4><p>By the end of this term, we are almost done with an MVP of survey6 such that all the three components are ready to be used. Tasks implemented in this sprint:</p><ol><li>continuous data collection and rsync transfer</li><li>connection and disconnection on the probe</li><li>regular sending of the heartbeats</li><li>event log at the server</li><li>probe CLI</li><li>probe packaging</li><li>data aggregator — cleaning hourly and daily data</li></ol><p>It was a great summer under the guidance of <a href="https://medium.com/u/cf89a403935f">Udesh Kumarasinghe</a>. Thank you for helping me in facing all the road blockers and bring this project to successful end.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5f5ef188a1d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/scorelab/survey6-sprint2-gsoc23-b5f5ef188a1d">Survey6 — Sprint2 @ GSOC’23</a> was originally published in <a href="https://medium.com/scorelab">SCoRe Lab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[gRPC : tips, tricks and testing]]></title>
            <link>https://medium.com/scorelab/grpc-tips-tricks-and-testing-1dbb89210cd3?source=rss-cb9af9aa224b------2</link>
            <guid isPermaLink="false">https://medium.com/p/1dbb89210cd3</guid>
            <category><![CDATA[protobuf]]></category>
            <category><![CDATA[grpc]]></category>
            <category><![CDATA[gsoc]]></category>
            <category><![CDATA[gsoc22]]></category>
            <category><![CDATA[grpc-testing]]></category>
            <dc:creator><![CDATA[Dhruvi Doshi]]></dc:creator>
            <pubDate>Tue, 06 Sep 2022 16:08:59 GMT</pubDate>
            <atom:updated>2022-09-06T16:54:25.980Z</atom:updated>
            <content:encoded><![CDATA[<h3>gRPC : tips, tricks and testing</h3><h4>GSoC Week 11–12 @SCoRe Lab</h4><p>gRPC is default for server to server communication these days.</p><h4>What is RPC?</h4><p>RPC stands for Remote Procedural Calls. Instead of calling methods on the client, we call methods on the server side. With this, it is easy to change the code on the server rather than changing code for each client. One more advantage on that front is, we can have our server and client in different languages according to our requirements.</p><h4>How RPC works?</h4><ol><li>serialize the arguments.</li></ol><blockquote><strong>Serialization</strong> is the process of converting a data object into a series of bytes that saves the state of the object in an easily transmittable form.</blockquote><p>2. Send the serialized code to server</p><p>3. De-serialize the arguments at server</p><p>4. Call the function at server</p><p>5. serialize the results and send it to the server</p><p>6. deserialize the result at the client.</p><blockquote>Protocol Buffers is the default serializer for gRPC. Protobufs are 4 times faster and generates 4 times smaller code than regular json serializtion.</blockquote><blockquote>gRPC uses HTTP2.0 which always <em>secure http </em>over TLS.</blockquote><h3>Timestamp</h3><p>We are going to import <strong><em>“google/protobuf/timestamp.proto” </em></strong>which is the definition by Google of what is at timestamp. And in our start request we can add a field called time which is of type <strong><em>google.protobuf.timestamp.</em></strong> Generate the code.</p><blockquote>Note that the generated type is not Python’s datetime.</blockquote><p>Importing Timestamp:</p><p><strong><em>from google.protobuf.timestamp_pb2 import Timestamp</em></strong></p><p>It’s a different type, and you need to do conversion back and forth every time. We set the request time field with <strong><em>fromDatetime(</em></strong><em>python-datetime</em><strong><em>)</em></strong> as follows:</p><p>If you have a Timestamp you can convert it to datetime using the <strong><em>toDateTime()</em></strong> method:</p><p>And there is also a method to get the current time. So you can do <strong><em>Timestamp().GetCurrentTime()</em></strong>.</p><h3>Serializing Protobuf structure to JSON</h3><p>Json is a very popular serialization format. Sometimes we like to take the types that were generated from protocol buffers and instead of serializing them to protocol buffers serialize them to json. When I want to convert it to json, I’m not going to use the json from the standard library but this json serialization library:</p><p><strong><em>from google.protobuf.json_format import MessageToJson</em></strong></p><p>It knows more about protocol buffers types and will do the right things. We get nice json document.</p><p>json = MessageToJson(proto_message)</p><h3>gRPC Testing</h3><p>Testing your code is important. gRPC has some utilities for testing. But I find out that only using pytest/unittest, you can test gRPC without the need for these test utilities. Here, it is for server testing:</p><ul><li>Create a <strong>request </strong>with all the data I need.</li><li>For the context use <strong>mock</strong> from the mock library</li><li>Create server.</li><li>Call the method with the request and the context.</li></ul><pre>context = MagicMock()</pre><pre>service = ClientConnectionService()</pre><pre>request = pb2.ClientConnectRequest(host_name = “User Test 2”)</pre><pre>request.request_epoch_time.FromDatetime(datetime.now())</pre><pre>response = service.ClientConnect(request,context)</pre><pre>self.assertEqual(response.connection_status,pb2.SUCCESS)</pre><pre>self.assertIsNotNone(response.uid)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1dbb89210cd3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/scorelab/grpc-tips-tricks-and-testing-1dbb89210cd3">gRPC : tips, tricks and testing</a> was originally published in <a href="https://medium.com/scorelab">SCoRe Lab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Debian packaging of a python project]]></title>
            <link>https://medium.com/scorelab/debian-packaging-of-a-python-project-ca4dfac9ac98?source=rss-cb9af9aa224b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ca4dfac9ac98</guid>
            <category><![CDATA[debian]]></category>
            <category><![CDATA[gsoc]]></category>
            <category><![CDATA[python-packaging]]></category>
            <category><![CDATA[stdeb]]></category>
            <category><![CDATA[gsoc22]]></category>
            <dc:creator><![CDATA[Dhruvi Doshi]]></dc:creator>
            <pubDate>Mon, 05 Sep 2022 11:58:45 GMT</pubDate>
            <atom:updated>2022-09-06T16:54:43.426Z</atom:updated>
            <content:encoded><![CDATA[<p>GSoC Week 10 @SCoRe Lab</p><p>How do we distribute a python package that has multiple PyPi dependencies? Any project with debian dependencies is easy enough to package:</p><ul><li>we mention dependencies in the <em>control file</em> of the source package</li><li>have executable files in /usr/bin</li><li>the project files in /usr/share</li></ul><p>and we are done with it!</p><p>However, when we have pip dependencies, what about the source files of those? Do we get them on the fly on the user machine or should we bundle the source code with our project code? <a href="https://askubuntu.com/questions/327543/how-can-a-debian-package-install-python-modules-from-pypi">This thread</a> has a nice discussion on the same.</p><h4>Approach 1</h4><p>One major approach is to create debian packages for the dependencies, , list them as requirements in your package, and ship all the .debs or source packages. This can be done using <strong>stdeb.</strong></p><ul><li>Create <strong><em>setup.py</em></strong></li><li>Install stdeb</li></ul><pre>pip install python-stdeb</pre><ul><li>This command creates /debian source package</li></ul><pre>python3 setup.py — command-packages=stdeb.command debianize</pre><p>Or</p><p>If you want to directly create .deb, use this command :</p><pre>python setup.py --command-packages=stdeb.command bdist_deb</pre><ul><li>Add install and postinst files in /debian [as per requirement, In my case:</li></ul><p>a.<em> Install </em>script copies .envand the service file</p><p>b. <em>Postinst</em> activates the service ]</p><ul><li>create .deb and /DEBIAN (binary package)</li></ul><pre>dpkg-buildpackage -b -rfakeroot -us -uc</pre><ul><li>Installaing the package</li></ul><pre>sudo apt-get install ./package_name.deb</pre><h4>Approach 2</h4><p>We could have installed the PyPi dependencies in the user system from postinstall script by doing pip install. It is a <em>serious</em> security risk, definitely a no-no. You wouldn’t even be able to <em>inspect</em> the dependencies by extracting the deb, because they are downloaded and installed at install time. It&#39;s an approach that completely bypass the repositories system. No concerned user would be happy with a package that, behind the scenes (and as root, remember!), downloads additional non trusted software from non trusted sources.</p><p>So we found a small way out. We create a new user while installing the packages, we install the dependencies in that user and keep our project code in that same user directory. That’s all. So we have have eliminated the problem of security by doing this as the installation does not affect entire system.</p><p>You can find the implementation of the above approach <a href="https://github.com/dhruvi29/survey6/tree/packaging/C%26C%20Server/debian">here</a>.</p><p>We than build the source package using:</p><pre>dpkg-buildpackage -b -rfakeroot -us -uc</pre><h4>References</h4><ol><li><a href="https://askubuntu.com/questions/327543/how-can-a-debian-package-install-python-modules-from-pypi">https://askubuntu.com/questions/327543/how-can-a-debian-package-install-python-modules-from-pypi</a></li><li><a href="https://pypi.org/project/stdeb/">https://pypi.org/project/stdeb/</a></li></ol><p>That’s all, we are done and dusted with packaging.</p><p>BR!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca4dfac9ac98" width="1" height="1" alt=""><hr><p><a href="https://medium.com/scorelab/debian-packaging-of-a-python-project-ca4dfac9ac98">Debian packaging of a python project</a> was originally published in <a href="https://medium.com/scorelab">SCoRe Lab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Packaging Overview]]></title>
            <link>https://medium.com/scorelab/packaging-overview-74aaeead3655?source=rss-cb9af9aa224b------2</link>
            <guid isPermaLink="false">https://medium.com/p/74aaeead3655</guid>
            <category><![CDATA[gsoc22]]></category>
            <category><![CDATA[gsoc]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[packaging]]></category>
            <dc:creator><![CDATA[Dhruvi Doshi]]></dc:creator>
            <pubDate>Sat, 03 Sep 2022 17:38:06 GMT</pubDate>
            <atom:updated>2022-09-06T16:28:32.205Z</atom:updated>
            <content:encoded><![CDATA[<h4>GSoC Week 8–9 @ScoRe Lab</h4><h3>What is package?</h3><p>A package is simply an archive that combines all the libraries and binaries ,configuration and all the dependencies required to install the programs (i.e application, software or languages)</p><h3>Why?</h3><p>Histrionically in UNIX, every program had to write compiled linked and run. Then UNIX got the ability to use libraries (“shared objects”), ELF executables, etc. To solve the task of building more complicated software easily, make was developed. Make uses an makefile we had to create the makefile on our own so this was also a laborious task.</p><p>The main problems with make file’s are</p><ul><li>The specified package is not present on the location.</li><li>Package is depend on another package.</li><li>If the downloaded package is not working properly.</li></ul><p>The above problem can be solved by manually downloading the package. But there may be an version problem that downloaded package version is differant than we required or does not support.</p><p>This is called an “Dependency Hell” which is solved by package manager. How exactly the package manger works and solve all this problem, we discuss in following section.</p><h3>Package Managers</h3><ol><li>For a <strong>Debian</strong> based distribution system i.e. Linux mint , ubuntu , Debian ,pure OS etc. The base package manager is <strong>DPKG</strong> (Debian package). the frontend package that is generally used is <strong>APT</strong> its like cherry on the ice-cream top. There are some traditional frontend package managers that is also used with <strong>DPKG</strong> is <strong>APT-GET.</strong></li><li>For a <strong>RPM</strong> based distribution system like fedora, centos ,RHEL , we use <strong>Red-hat package managers (rpm)</strong> . The base package manager for a <strong>RPM</strong> based distribution system is <strong>RPM</strong>. The frontend package managers that is used more often with rpm is<strong> YUM </strong>(<strong> YELLOW DOG</strong> <strong>Updater, Modified) .The more advanced version that we uses more often as a frontend package manger is DNF.</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*sn287gfP1QRVjrVYps4rUg.png" /></figure><h3>dpkg</h3><p>dpkg is a tool to install, build, remove and manage Debian packages. The primary and more user-friendly front-end for dpkg is aptitude(1). dpkg itself is controlled entirely via command line parameters, which consist of exactly one action and zero or more options. The action-parameter tells dpkg what to do and options control the behavior of the action in some way.</p><h3>dpkg suite</h3><p>dpkg — Debian’s package maintenance system</p><p>This is the dpkg suite of programs that form the foundation of the Debian’s<br>package management system; on the lower layer there are ‘dpkg-deb’ and<br>‘dpkg-split’ programs handling the binary formats, and ‘dpkg-source’ program<br>handling the source formats; there is a collection of tools to handle building<br>source packages into binary packages; there is the medium-level and less<br>user-friendly command-line interface (CLI) in the form of the ‘dpkg’ command;<br>and then there is the terminal user interface (TUI) ‘dselect’ program (which<br>has gone out of preference in favor of the apt (CLI) and aptitude (TUI)<br>programs).</p><p>The dpkg suite also includes some other programs currently maintained<br>on external repositories, namely ‘dpkg-repack’, ‘dpkg-www’, ‘dupload’<br>and ‘debsig-verify’.</p><h3>.deb</h3><p>A <strong>deb</strong> file is an archive that contains data. Marked with the .deb extension, it is used to easily distribute and install programs for Linux Debian and derivatives. Deb files are handy when your app needs to take care of additional dependencies, integrate itself with the desktop, run pre and post install scripts and so on.</p><p>Internally, a deb package contains a collection of folders that mimics a typical Linux file system, such as /usr, /usr/bin, /opt and so on. A file put in one of those directories will be copied to the same location in the actual file system during installation. So, for example a binary file put into &lt;.deb&gt;/usr/local/bin/binaryfile will be installed to /usr/local/bin/binaryfile.</p><h3>Source directory</h3><p>package contains the following files in its debian/ directory:</p><ul><li>changelog</li><li>compat</li><li>control</li><li>copyright</li><li>docs</li><li>node-libravatar.install</li><li>rules</li><li>source/format</li><li>watch</li></ul><p>A very good reference apart from the official documentation is this:</p><p><a href="https://feeding.cloud.geek.nz/posts/whats-in-a-debian-directory/">https://feeding.cloud.geek.nz/posts/whats-in-a-debian-directory/</a></p><h3>Binary directory</h3><p>Create a temporary working directory to make your package in. On the outside instead, all deb package files follow a specific naming convention:</p><pre>&lt;name&gt;_&lt;version&gt;-&lt;revision&gt;_&lt;architecture&gt;</pre><p>That is:</p><ul><li>&lt;name&gt; – the name of your application;</li><li>&lt;version&gt; – the version number of your application;</li><li>&lt;revision&gt; – the version number of the current deb package;</li><li>&lt;architecture&gt; – the hardware architecture your program will be run on.</li></ul><p>Put your program files where they should be installed to on the target system. For example, suppose you want your program to be installed to /usr/local/bin:</p><pre>mkdir -p hello_1.0-1_arm64/usr/local/bin</pre><p>The -p flag to the mkdir command will create nested directories. Then copy the executable file in there:</p><pre>cp ~/YourProjects/Hello/hello hello_1.0-1_arm64/usr/local/bin</pre><p>The control file lives inside the DEBIAN directory. Mind the uppercase: a similar directory named debian (lowecase) is used to store source code for the so-called <a href="https://www.debian.org/doc/debian-policy/ch-source.html"><strong>source packages</strong></a>. This tutorial is about binary packages, so we don&#39;t need it.</p><p>Let’s create the DEBIAN folder first:</p><pre>mkdir helloworld_1.0-1_arm64/DEBIAN</pre><p>And then create the empty control file:</p><pre>touch helloworld_1.0-1_arm64/DEBIAN/control</pre><p>Open the file previously created with your text editor of choice. The control file is just a list of data fields. For binary packages there is a minimum set of mandatory ones:</p><ul><li>Package – the name of your program;</li><li>Version – the version of your program;</li><li>Architecture – the target architecture;</li><li>Maintainer – the name and the email address of the person in charge of the package maintenance;</li><li>Description – a brief description of the program.</li></ul><p>For example:</p><pre>Package: hello<br>Version: 1.0<br>Architecture: arm64<br>Maintainer: Internal Pointers &lt;info@internalpointers.com&gt;<br>Description: A program that greets you.<br> You can add a longer description here. Mind the space at the beginning of this paragraph.</pre><p>The control file may contain additional useful fields such as the <a href="https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections">section</a> it belongs to or the <a href="https://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps">dependency list</a>. The latter is extremely important in case your program relies on external libraries to work correctly. You can fill it manually if you wish, but there are helper tools to ease the burden. I will show you how in the next few paragraphs.</p><h3>Building</h3><p>This is the last step. Invoke dpkg-deb as following:</p><pre>dpkg-deb --build --root-owner-group &lt;package-dir&gt;</pre><p>So in our example:</p><pre>dpkg-deb --build --root-owner-group &lt;helloworld_1.0-1_arm64&gt;</pre><p>The --root-owner-group flag makes all deb package content owned by the root user, which is the standard way to go. Without such flag, all files and folders would be owned by your user, which might not exist in the system the deb package would be installed to.</p><p>The command above will generate a nice .deb file alongside the working directory or print an error if something is wrong or missing inside the package. If the operation is successful you have a deb package ready for distribution.</p><h3>Installation</h3><pre>sudo apt-get install package.deb</pre><h3>Final words</h3><p>Now that we know packaging we will see different ways of packaging of python application in the next blog.</p><h3>References</h3><ol><li><a href="https://medium.com/@knoldus/working-of-package-manager-in-linux-775ca131c388">https://medium.com/@knoldus/working-of-package-manager-in-linux-775ca131c388</a></li><li><a href="https://sauravstwt.medium.com/package-management-in-linux-7db916968247">https://sauravstwt.medium.com/package-management-in-linux-7db916968247</a></li><li><a href="https://www.internalpointers.com/post/build-binary-deb-package-practical-guide">https://www.internalpointers.com/post/build-binary-deb-package-practical-guide</a></li><li><a href="https://feeding.cloud.geek.nz/posts/whats-in-a-debian-directory/">https://feeding.cloud.geek.nz/posts/whats-in-a-debian-directory/</a></li><li><a href="https://www.senties-martinelli.com/articles/debian-packages">https://www.senties-martinelli.com/articles/debian-packages</a></li><li><a href="https://github.com/FooBarWidget/debian-packaging-for-the-modern-developer">https://github.com/FooBarWidget/debian-packaging-for-the-modern-developer</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74aaeead3655" width="1" height="1" alt=""><hr><p><a href="https://medium.com/scorelab/packaging-overview-74aaeead3655">Packaging Overview</a> was originally published in <a href="https://medium.com/scorelab">SCoRe Lab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scripting Installation]]></title>
            <link>https://medium.com/scorelab/scripting-installation-83b01933058d?source=rss-cb9af9aa224b------2</link>
            <guid isPermaLink="false">https://medium.com/p/83b01933058d</guid>
            <category><![CDATA[gsoc]]></category>
            <category><![CDATA[scripting]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[aliasing]]></category>
            <category><![CDATA[gsoc-2022]]></category>
            <dc:creator><![CDATA[Dhruvi Doshi]]></dc:creator>
            <pubDate>Tue, 30 Aug 2022 17:48:38 GMT</pubDate>
            <atom:updated>2022-09-06T16:28:10.395Z</atom:updated>
            <content:encoded><![CDATA[<h3>Installation scripting guide</h3><h4><a href="https://medium.com/scorelab/some-implementation-touches-ff7c8e844c1e?source=your_stories_page-------------------------------------">GSoC Week 6–7@SCoRe Lab</a></h4><p>Interesting developments this week!! It started small and led to a completely different output.</p><p>As stated in the earlier blog, I had to write an installation script. Installation steps at this point of time are as follows:</p><ol><li>clone the repository</li><li>create a virtual env</li><li>install pip requirements</li><li>copy service file in its directory</li><li>get the service up and running</li></ol><p>User would clone the directory and then run <strong>setup.bash</strong>. Lets start with scripting now. I would give you a gist of all the concepts used and combine them all to write and execute our script.</p><h3>Building Blocks<a href="https://emojipedia.org/puzzle-piece/">🧩</a></h3><p>Unix has more than one possible shell: C Shell (csh), Bourne Shell (sh), Korn Shell(ksh), Bourne Again Shell (bash).</p><h4>Executing v/s Sourcing a bash script</h4><pre>A<br>&gt; ./myscript<br><br>B<br>&gt; source myscript</pre><blockquote>The differences are:</blockquote><blockquote>When you<strong> <em>execute</em></strong> the script you are opening a <em>new</em> shell, type the commands in the new shell, copy the output back to your current shell, then close the new shell. Any changes to environment will take effect only in the new shell and will be lost once the new shell is closed.</blockquote><blockquote>When you <strong><em>source</em></strong> the script you are typing the commands in your <em>current</em> shell. Any changes to the environment will take effect and stay in your current shell.</blockquote><p>Read <a href="https://superuser.com/questions/176783/what-is-the-difference-between-executing-a-bash-script-vs-sourcing-it#:~:text=Executing%20a%20script%20will%20run,use%20execute%20otherwise">here</a> for detailed reference.</p><h4>.bashrc</h4><p>The .bashrc file is a script file that’s executed when a user logs in. The file itself contains a series of configurations for the terminal session. This includes setting up or enabling: coloring, completion, shell history, command aliases, and more. The ~/.bashrc file determines the behavior of interactive shells. It gets executed every time a user starts up a fresh terminal session in interactive mode on their Linux system.</p><blockquote>Location: ~/.bashrc</blockquote><p>(~ Tilde indicates user home directory)</p><p>PS: You can find a skeleton of bashrc in /etc/skel/.bashrc. If different users want different bash configurations then you must put a .bashrc file in that users home folder.</p><h4>Aliasing</h4><p>A Bash alias is basically a shortcut you can set for a command. If you have to type some long command out often, you can shorten it or make it more memorable with a Bash alias.</p><blockquote>$ alias start= “systemctl cnc-server start”</blockquote><p>Now, you can just use the command start whenever you want.</p><p>However, there’s a catch: this is only in your current shell session. Close your window, and this alias is gone.</p><p>If you plan on keeping that alias for the future, you will have to open up either your ~/.bash_profile or ~/.bashrc files with a text editor and save the aliases directly there. You can also organize the aliases in ~/.bash_aliases and run that from ~/.bashrc as follows:</p><pre>if [ -f ~/.bash_aliases ]; then<br>    . ~/.bash_aliases<br>fi</pre><h3>Putting it all together</h3><p>Compilation was pretty easy, put all the commands that you would have entered while manual installation.</p><p>Additionally I used system aliasing to start, stop and view status of the service. I wrote an aliasing script and catted it to ~/.bash_aliases. Aliasing gave better accessibility, look and feel.</p><p>I had used function aliasing so I could accept arguments. Here is the code snippet of aliasing.</p><pre>function cncserver { <br>if [ -z “$1” ]; <br>then echo “Enter a command: start / stop” <br>elif [ “$1” = “start” ]; <br>then systemctl start survey6_server <br>elif [ “$1” = “stop” ]; <br>then systemctl stop survey6_server <br>elif [ “$1” = “status” ]; <br>then systemctl status survey6_server <br>else echo “Command not supported” <br>fi <br>} <br>alias cncserver=cncserver</pre><p>We’ll be packaging the project in the next blog :)</p><p>Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83b01933058d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/scorelab/scripting-installation-83b01933058d">Scripting Installation</a> was originally published in <a href="https://medium.com/scorelab">SCoRe Lab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Some implementation touches..]]></title>
            <link>https://medium.com/scorelab/some-implementation-touches-ff7c8e844c1e?source=rss-cb9af9aa224b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff7c8e844c1e</guid>
            <category><![CDATA[gsoc-2022]]></category>
            <dc:creator><![CDATA[Dhruvi Doshi]]></dc:creator>
            <pubDate>Sat, 23 Jul 2022 06:06:43 GMT</pubDate>
            <atom:updated>2022-07-23T06:06:43.218Z</atom:updated>
            <content:encoded><![CDATA[<h4>GSoC Week 5 @SCoRe Lab</h4><p>Well, nothing very fancy this week. Basics and essentials. I managed to disconnect the client with one gRPC call. It disconnects the client from the server. The server basically maintains two tables: one for connected and other for disconnected clients or maybe you can call it archives. The archives contain the hostname and the last active time of the probe. So the server, on disconnection removes the probe info from the connected clients table to put it into the archives.</p><p>With this we are almost done with the massive issue that we started in week 3. The <a href="https://github.com/web-telescope/survey6/pull/7">PR</a> was reviewed and merged.</p><h4>Plans for week 6:</h4><p>1. Automation of installation using bash scripts</p><p>2. Bash script aliasing for running the commands: starting and stopping of server, health checks to start with.</p><p>3. Unit testing of code written so far.</p><p>4. Error handling and logging.</p><p>Project: <a href="https://github.com/web-telescope/survey6">Survey6</a></p><p>See you with next weeks updates! Tc.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff7c8e844c1e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/scorelab/some-implementation-touches-ff7c8e844c1e">Some implementation touches..</a> was originally published in <a href="https://medium.com/scorelab">SCoRe Lab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[System Service & DB]]></title>
            <link>https://medium.com/scorelab/system-service-db-683b6c652076?source=rss-cb9af9aa224b------2</link>
            <guid isPermaLink="false">https://medium.com/p/683b6c652076</guid>
            <category><![CDATA[bash]]></category>
            <category><![CDATA[systemd]]></category>
            <category><![CDATA[sqlite]]></category>
            <dc:creator><![CDATA[Dhruvi Doshi]]></dc:creator>
            <pubDate>Wed, 13 Jul 2022 03:03:53 GMT</pubDate>
            <atom:updated>2022-07-13T08:40:59.120Z</atom:updated>
            <content:encoded><![CDATA[<h4>GSOC Week 4@SCoRe Lab</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DJjYChlRAMtcgADS" /><figcaption>Photo by <a href="https://unsplash.com/@alfonsmc10?utm_source=medium&amp;utm_medium=referral">Alfons Morales</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>We use SQLite for data persistence here. We need the list of registered probes to accept data from valid users and trace the health of each of them. SQLite is pretty easy to use with python3. It comes bundled with python3 so we don’t need to install any separate packages.</p><p>Standard SQL queries work with SQLite too. Quoting resources that I refer to for using SQLite in python:</p><ol><li><a href="https://medium.com/analytics-vidhya/programming-with-databases-in-python-using-sqlite-4cecbef51ab9">https://medium.com/analytics-vidhya/programming-with-databases-in-python-using-sqlite-4cecbef51ab9</a></li><li><a href="https://towardsdatascience.com/python-sqlite-tutorial-the-ultimate-guide-fdcb8d7a4f30">https://towardsdatascience.com/python-sqlite-tutorial-the-ultimate-guide-fdcb8d7a4f30</a></li></ol><p>&amp; the official docs of course.</p><p>Whenever I receive a new request from the probe to connect, I have to save its details in my server’s registry. The fields that I would require for the probe are <strong>hostname, registered time, last active time, current status and last time when data was sent.</strong></p><p>Then, I was required to run the server as the system service. You might have already guessed it what I might have used: <strong>Systemd</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*_PL2TPuTkOXQhqQKfDtxFg.png" /></figure><p>Creating services is a good thing when you need to run a certain application every time your linux computer boot for example. Basically, Systemd is an <strong><em>init system. </em></strong>We do have some other init systems like SystemV. There are plenty of resources out on the internet. Please allow me to help you out with a few I like:</p><ol><li><a href="https://medium.com/@benmorel/creating-a-linux-service-with-systemd-611b5c8b91d6">https://medium.com/@benmorel/creating-a-linux-service-with-systemd-611b5c8b91d6</a></li><li><a href="https://www.golinuxcloud.com/beginners-guide-systemd-tutorial-linux/">https://www.golinuxcloud.com/beginners-guide-systemd-tutorial-linux/</a></li><li><a href="https://medium.com/the-code-vault/systemd-simple-service-examples-ce586afeed27">https://medium.com/the-code-vault/systemd-simple-service-examples-ce586afeed27</a></li><li><a href="https://medium.com/@vinicenter/creating-a-service-in-linux-using-systemd-f2ded253cd92">https://medium.com/@vinicenter/creating-a-service-in-linux-using-systemd-f2ded253cd92</a></li><li><a href="http://0pointer.de/blog/projects/systemd.html">http://0pointer.de/blog/projects/systemd.html</a></li></ol><p>Just to refresh your memory, I would like to re-iterate through the difference between <strong>BASH</strong> &amp; <strong>SH.</strong></p><p>BASH is Bourne Again SHell. It is the superset of SH &amp; BASH is a lil more powerful than SH. BASH supports more commands. A very significant example is <strong>source. </strong>source is a command implemented in bash, but not in sh. { Source, as in, <strong><em>source venv/bin/activate </em></strong>}</p><p>This is a trivial pointer rather but might save you sometimes :)</p><p>Thank you for reading it all.</p><p>Happy Coding!! BR!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=683b6c652076" width="1" height="1" alt=""><hr><p><a href="https://medium.com/scorelab/system-service-db-683b6c652076">System Service &amp; DB</a> was originally published in <a href="https://medium.com/scorelab">SCoRe Lab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Server: gRPC & Protobuf]]></title>
            <link>https://medium.com/scorelab/the-server-grpc-protobuf-98a766b6b71b?source=rss-cb9af9aa224b------2</link>
            <guid isPermaLink="false">https://medium.com/p/98a766b6b71b</guid>
            <category><![CDATA[python-packages]]></category>
            <category><![CDATA[grpc]]></category>
            <category><![CDATA[protocol-buffers]]></category>
            <category><![CDATA[protobuf]]></category>
            <dc:creator><![CDATA[Dhruvi Doshi]]></dc:creator>
            <pubDate>Wed, 13 Jul 2022 03:03:08 GMT</pubDate>
            <atom:updated>2022-07-13T03:03:08.449Z</atom:updated>
            <content:encoded><![CDATA[<h4>GSOC Week 3@SCoRe Lab</h4><p>This week started off with creating the C&amp;C Server. The server is built using <strong>gRPC</strong>.</p><h3>gRPC ?</h3><p><a href="https://grpc.io/">gRPC</a> is a modern open source high performance Remote Procedure Call (RPC) framework that can run in any environment. <a href="https://towardsdatascience.com/reasons-to-choose-grpc-over-rest-and-how-to-adopt-it-into-your-python-apis-197ac28e22b4">This</a> is a good article that might convince you if you gotta ask “why gRPC?”.</p><blockquote>That is its main advantage over REST: gRPC, in most cases, is way faster and more robust, as it defines a specific set of rules each request and response should adhere to.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*bh_u1lX3mX4hur-54wIOFg.png" /></figure><p>By default, gRPC uses <a href="https://developers.google.com/protocol-buffers/docs/overview">Protocol Buffers</a>, Google’s mature open source mechanism for serializing structured data (although it can be used with other data formats such as JSON).</p><p>For most of the message transfers of our project, we too use the protobuf!</p><h3>Protocol Buffers</h3><blockquote>Protocol buffers are Google’s language-neutral, platform-neutral, extensible mechanism for serializing structured data — think XML, but smaller, faster, and simpler.</blockquote><p>Protocol Buffers support a wide variety of languages and data types. The <a href="https://developers.google.com/protocol-buffers/docs/proto3">official documentation</a> of protocol buffers is very well maintained &amp; easy to understand.</p><p>So, in this week, I sat down to write the protobuf definitions for Survey6. The services mainly include connecting/disconnecting the probes to/from the server and the health check mechanism. The definitions include the function calls and the message formats. I kept in mind <a href="https://developers.google.com/protocol-buffers/docs/style">this</a> style guide to maintain the quality of my code at the same time.</p><p>P.S: Protobufs also support Timestamp datatype :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b7siaQBHwkuz2gDmv8ygHg.png" /></figure><p>Directory structure was also setup during this week. Python3 does no more require <strong><em>__init__.py </em></strong>to initialize a package. A lovely guide to python packaging and modules is <a href="https://towardsdatascience.com/how-to-fix-modulenotfounderror-and-importerror-248ce5b69b1c">here</a>.</p><p>I hope this helps :)</p><p><strong>Up Next:</strong> Setting up system service &amp; connecting to database.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98a766b6b71b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/scorelab/the-server-grpc-protobuf-98a766b6b71b">The Server: gRPC &amp; Protobuf</a> was originally published in <a href="https://medium.com/scorelab">SCoRe Lab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Capturing the packets…]]></title>
            <link>https://medium.com/scorelab/gsoc-week-1-2-score-lab-22aa58610f37?source=rss-cb9af9aa224b------2</link>
            <guid isPermaLink="false">https://medium.com/p/22aa58610f37</guid>
            <dc:creator><![CDATA[Dhruvi Doshi]]></dc:creator>
            <pubDate>Tue, 28 Jun 2022 21:03:15 GMT</pubDate>
            <atom:updated>2022-07-12T16:38:24.994Z</atom:updated>
            <content:encoded><![CDATA[<h4>GSOC Week 1–2 @SCoRe Lab</h4><p>The coding period officially began on 13th June’22 with a lot of excitement. Here is an update from week 1 &amp; week 2 ….</p><p>Survey6 is a fresh project. The initial push that I required was provided by mentor <a href="https://medium.com/u/414a4b05818d">Ravindu De Silva</a> (Thanks) by creating a GitHub issue. The task at hand was to create first function of the code base : to collect, annotate and store the captured IPv6 packets on the probe. Fairly easy! <a href="https://scapy.net/">Scapy</a> helped me with collection and storage. Guess what I did with annotation? After breaking my head all over, I made system calls to annotate file metadata which I later got to know is local to the file system. What a rookie!</p><p>When I was pretty much done writing the piece of code, It was a mere 20 line function! I knew something was missing then. Even though size of code that we write is secondary, I had missed big time error handling! Absolutely, feel free to judge me. The point of me writing this blog is not to show how stupid one can be, instead, I intend to help someone from averting such mistakes and maybe understand that this is how we grow by making mistakes and having mentors to guide you out. I learnt a lot from the elaborate reviews by my mentors <a href="https://medium.com/u/414a4b05818d">Ravindu De Silva</a> and <a href="https://medium.com/u/a8e9dcc1ac9a">Maanas Talwar</a>.</p><p>I improved upon error handling, error logging, project structure management and of course metadata annotation. Good coding practices also including usage of environment variables whenever we use variables. At some point during development you will need to think about the environment in which your application will run and the potentially sensitive or environment specific information your application will need to perform its tasks. Where I am required to transfer the files, annotating file’s system meta data won’t help. I had to make something portable. On receiving some advice on the same, we finally stored the metadata in a .<em>json</em> file.</p><p>In the second week, I made changes corresponding to all the reviews and the resulting code was a <em>lottt better!!! </em>I was indeed happy with the final code. By then I had also improved upon my writing style and I started figuring out the best practices of writing a python code. But the feeling of my first PR being merged was🔥.</p><h4>Resources</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wmeE6FcH-9THHJwd" /></figure><p>Here is a list of some good resources that had helped me (just in case) :<br>1. <a href="https://eli.thegreenplace.net/2008/08/21/robust-exception-handling/">Robust Error Handling</a><br>2. <a href="https://dev.to/jakewitcher/using-env-files-for-environment-variables-in-python-applications-55a1">Using environment variables with python</a><br>3. <a href="https://github.com/github/gitignore/blob/main/Python.gitignore">Use this .gitignore template by GitHub</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22aa58610f37" width="1" height="1" alt=""><hr><p><a href="https://medium.com/scorelab/gsoc-week-1-2-score-lab-22aa58610f37">Capturing the packets…</a> was originally published in <a href="https://medium.com/scorelab">SCoRe Lab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GSOC’22 @SCoRe Lab]]></title>
            <link>https://medium.com/scorelab/gsoc22-score-lab-3f02cdb91a22?source=rss-cb9af9aa224b------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f02cdb91a22</guid>
            <category><![CDATA[scorelab]]></category>
            <category><![CDATA[gsoc-2022]]></category>
            <category><![CDATA[gsoc]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Dhruvi Doshi]]></dc:creator>
            <pubDate>Sun, 12 Jun 2022 19:47:56 GMT</pubDate>
            <atom:updated>2022-06-12T19:47:56.593Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>It all starts from here…</em></strong></p><p>When I thought of entering the world of open source, what could be a better platform than GSOC? I browsed through various organizations from the past year GSOC; I went through their projects, tech stack &amp; code base. Honestly, all of it was overwhelming for me. Either the tech stack was completely alien to me or the topics did not appeal my interest. I was ready to give up. Here, I would like to thank my mother, peers and seniors for pushing me and keeping me alive.</p><p>I continued my search until in March I came across Survey6 Project under Web Telescope |SCoRe Lab. My interest in cybersec and networking was matched by Web Telescope.</p><h3>About Web Telescope</h3><p>Web Telescope is a sub-org of SCoRe Lab that contributes and promotes cybersecurity research.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*eqXqRbB_B8QMgtUKMUPleQ.jpeg" /></figure><h3>My Project: Survey6</h3><p>To aid cybersecurity researchers in their study about IPv6 research and promote its study, people at Web Telescope have come up with a tool called Survey6 that collects all the IPv6 packets via probes and send the collected packets to the server where the packets are processed and stored for further studies. The collection is done both actively and passively.</p><h3>My Task</h3><p>My task here is to create a passive packet collector(probe) that would be Linux based CLI application, the server that would collect the packets and set up effective communication and packet files transfer between the probe and server.</p><p>I saw this as an immense opportunity to grow and learn. After contacting the mentor, understanding the project, getting my doubts cleared, learning some of the tech stack and making a prototype, I finally typed a proposal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uYD1cbkEi6h0Zzb8FzGFtA.png" /></figure><p>And, there was a long wait until the selection announcement ( 20th May, 2022 ). I was indeed thrilled.</p><p>Well, then started community bonding period: I had a meeting with my mentor where I got to know so much more about the project, aligned my vision of the project with the vision of the organization. We refined certain implementation details and discussed the tech stack. I used the rest of my period to get familiar with other tools from the tech stack and architecture details.</p><h3>Gratitude</h3><p>I am grateful to my mentor, <a href="https://medium.com/u/414a4b05818d">Ravindu De Silva</a> for the selection. I also thank my mom and my peers at <a href="https://sravjti.in/">Society of Robotics &amp; Automation</a>, VJTI who motivated me to make an application. Special thanks to <a href="https://medium.com/u/67b0d46147fd">Kush Kothari</a> for helping me review my application. Sincere thanks to all those people whom I have crossed path with.</p><p>I am looking forward to a great summer with SCoRe Lab and hope my contributions make some difference.</p><p>Thanks for reading all the way here. I’ll keep you updated with my updates. Stay tuned!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f02cdb91a22" width="1" height="1" alt=""><hr><p><a href="https://medium.com/scorelab/gsoc22-score-lab-3f02cdb91a22">GSOC’22 @SCoRe Lab</a> was originally published in <a href="https://medium.com/scorelab">SCoRe Lab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>