Saturday, September 17, 2022
HomeCyber SecurityWhich Programming Language Ought to You Use? | by Teri Radichel |...

Which Programming Language Ought to You Use? | by Teri Radichel | Cloud Safety | Sep, 2022


ACM.53 Selecting a programming language for brief time period and long run initiatives

It is a continuation of my collection of posts on Automating Cybersecurity Metrics.

Typically a remark fully derails what I used to be planning to publish subsequent. It is a matter I used to be occupied with however hadn’t wished to cease to put in writing it simply but. Then an individual made a touch upon LinkedIn about my selection of programming and why wasn’t I selecting an “power environment friendly programming language?” The remark piqued my curiosity and prompted me to put in writing about it before later.

There are such a lot of issues I have to cowl and full and I hate disrupting the present movement, however this individual’s remark must be addressed for a number of causes. One being the way by which the individual made the remark. The opposite has to with world occasions proper now and likewise, curiosity that too usually distracts me. =)

This individual is in Europe, and Europe is going through an enormous downside with power because of the Ukraine warfare should you haven’t been following, so power effectivity could also be prime of thoughts. Right here in america, a legislation was not too long ago handed that permits folks to get all types of credit for all method of power environment friendly dwelling upgrades and automobiles to attempt to get off our reliance on non-renewable power sources.

With the problems occurring associated to blocking the movement of power to Germany from Russia, for instance, evidently it could be a good suggestion to do what we will to preserve and enhance our effectivity in use of power.

Don’t hate at me in case you are a US Republican. I'm an Unbiased, have voted for each events prior to now as a result of neither of them get it proper for my standpoint, and I hate politics. To boil it down, I believe we must be fiscally accountable and fewer grasping. I’m simply making an attempt to resolve issues and chopping down on power use or shifting to renewables looks as if a good suggestion for the brief and long run. When you disagree, I am not right here for that. I am right here to deal with this individual's feedback as to why I didn't select an "power environment friendly programing language."

Power environment friendly programming languages

I regarded into the idea of power environment friendly programming and located a hyperlink to a report. I’m not clicking on the precise report simply but as a result of I’m a tad busy and wish to judge the contents of the file in a safe surroundings.

I discovered a abstract on a web site I acknowledge:

View the above article for the whole desk

Having developed numerous completely different functions and likewise utilizing completely different instruments which have wildly completely different consumption necessities when penetration testing I used to be curious in regards to the selection of code used for the exams. For instance, once I’m performing a penetration check exercise like brute forcing passwords that may extra CPU energy. Once I’m testing DOM XSS which may be loading a number of headless browsers behind the scenes and consuming tons of reminiscence. I’m to the purpose the place I exploit completely different AWS EC2 configurations for several types of exams.

It appears like they pulled this code from some benchmark exams. This code comes with the next caveats from the builders:

The builders themselves spotlight the truth that these doing analysis ought to train warning when utilizing such microbenchmarks:

[…] the JavaScript benchmarks are fleetingly small, and behave in methods which can be considerably completely different than the actual functions. We’ve got documented quite a few variations in habits, and we conclude from these measured variations that outcomes based mostly on the benchmarks might mislead JavaScript engine implementers. Moreover, we observe attention-grabbing behaviors in actual JavaScript functions that the benchmarks fail to exhibit, suggesting that beforehand unexplored optimization methods could also be productive in observe.

My curiosity leads me to the next questions:

  • Has the report been peer-reviewed and validated? A developer on considered one of my groups as soon as informed me that he benchmarked and located that python is quicker than golang, which I used to be constructive was inaccurate. One other developer identified the flaw in his logic which skewed the outcomes.
  • How a lot is the precise quantity of power financial savings when it comes to a real-world software. Is it important? I’m positive it might be. I’m additionally positive it varies by structure of the appliance. For what I’m implementing at present in Lamba, I actually can’t picture there could be any important distinction in my case — yours could also be completely different.
  • Might the code used on this check be additional optimized to cut back power utilization, the identical method you optimize packages for reminiscence utilization and efficiency? Maybe that was considered on this report. However maybe a language decrease on the record might be optimized for power effectivity over reminiscence or CPU utilization. You’ll must learn it your self to know the small print if you wish to discover that path.
  • This check doesn’t consider the general software structure. Typically you don’t get an entire image of an software’s efficiency till you set all of the items collectively and check them as a complete. Though I perceive the idea of Huge O Notation I by no means favored dwelling on it an excessive amount of. (OK truthfully, I don’t prefer it in any respect. Although I perceive the ideas of a hash retrieving knowledge sooner I’d identical to to talk in plain English.) Additionally, typically when you begin writing your code and do an precise POC you will see that points you didn’t consider and get rather more correct efficiency outcomes that consider issues like community latency and retries.
  • Would the power effectivity change for various functions relying on what kind of {hardware} they run on? For instance, possibly Java is extra power environment friendly on one structure and Golang is extra power environment friendly on one other and vice versa.

Though I considered the above questions, I think about the power effectivity record is usually good data with some potential variance in numerous situations. Python is a much less environment friendly language so I’d count on that usually, sooner languages could be extra power environment friendly.

However right here’s what can also be an attention-grabbing idea. C and C++ are within the prime 5 for power, time, and reminiscence. So we should always all simply change proper now to a type of two languages as a result of they appear like one of the best. Proper? Is that what individuals are doing?

Selecting a language that helps you forestall safety errors

Why don’t folks use C/C++ for all the things? As a result of it’s very sophisticated to get your code proper and maintain it free from errors, that’s why. It’s a brilliant highly effective device that means that you can squeeze each drop out of your compute assets however that comes with a value. Don’t make a mistake with pointers. Watch out for all types of safety issues that different languages defend you from equivalent to buffer overflows, concurrency errors, and safety from formatting assaults to call a couple of.

I’ve programmed in Java for over 20 years. Java received a nasty rap, I imagine, because of the browser plugin that was the supply of many, many, safety issues. Though Java has had safety points and lots of of them with that browser plugin, out of the gate it helped many organizations restrict the variety of buffer overflows of their code in comparison with C/C++. That was one of many largest safety issues in code on the time. It additionally runs on a number of platforms.

I’ve additionally written about my curiosity in Golang, a language that may assist forestall concurrency issues — that are very laborious issues to troubleshoot and might result in numerous varieties of safety assaults:

I thought-about utilizing Golang for my code in these posts and I nonetheless may however why didn’t I begin with Golang? It’s a extra environment friendly program so my code will in all probability run sooner (although you shouldn’t make assumptions and at all times benchmark your code).

I’m additionally actually interested in Rust.

Code for studying

Why did I select to start out with Python?

Typically when making an attempt to show folks one thing, you select one thing that’s accessible and straightforward for them to study. Once I wrote my first automation framework a very long time in the past, which I drastically enhance in my class labs, I wrote it fully with the AWS CLI and Bash, of all issues. Why?

As a result of each safety class I took was heavy in bash and command line scripts. My target market was safety professionals, and I figured it could be simpler for them to know the ideas utilizing bash. It’s not how I’d do it or will do it in the end on this weblog collection as a result of I believe many safety professionals are previous that time now.

However on the time there have been no cloud safety courses from SANS or anyplace else. I wrote it to point out safety professionals what is feasible within the cloud and easy methods to deploy a safety equipment within the cloud on the time when most of them have been saying cloud would by no means occur and it was not safe. If the language was over their heads they wouldn’t use it or see the purpose.

I imply, if you wish to be power environment friendly and write essentially the most performant code attainable, why not use Meeting? I wager it’s power environment friendly. Folks don’t write packages instantly in Meeting as a result of it’s laborious to learn and complex to do. It will be very error inclined and sure many safety flaws would exist in newbie code. Might I one way or the other make Meeting code work for my functions? Maybe I may get a naked steel occasion. I’m undecided however I don’t actually care as a result of I’m not going to try this. Clearly.

I’ve needed to take care of Meeting code in reverse engineering malware courses and superior penetration testing courses. In my case, I can discover numerous bugs with out going that deep, but when I ever have time I’d get into that extra simply because it’s attention-grabbing and enjoyable. There are such a lot of safety issues at greater ranges, I determine we will begin there for the purchasers I typically serve.

Python is simple to learn and study. The Python SDK has been round a very long time and might be some of the absolutely developed AWS SDKs together with Java. One of many problems for instructing programming lately is all of the configuration and metadata surrounding the precise code. That’s one of many good issues about AWS Lambda and Batch. It abstracts a few of these issues away. Nevertheless it’s nonetheless a bit simpler to study programming in Python. Though I extremely suggest type-checking, it may be cumbersome for newbies, as is compiling code. I’m slowly introducing issues akin to design patters as we go slightly than dumping them on my readers out of the gate.

By the way in which — I volunteered to assist children study to program as soon as however they have been utilizing some form of GUI drag and drop factor. I discovered to program in TI Primary from a e book on the age of 12. I couldn’t do it. I needed to bail out. If these ideas are good for very younger children that’s superior, however I can’t educate programming like that. I wish to educate precise code and I believe it's attainable — should you begin with the correct programming language and ideas.

Python is extensively used. If somebody learns Python there’s probability that will likely be relevant for the following safety or development-related job to which they apply. Rust and Golang are up and coming. Java and C# could be stable selections. However Python is all over the place.

I at all times inform folks when asking me what programming language or expertise they need to study — Go take a look at job postings. Discover the businesses the place you wish to apply, see what applied sciences they’re utilizing, and study that. When you wished to use at Google maybe you’d study Golang. When you have been going to attempt to get a job at Fb you may decide to study React. Perhaps for AWS you’d study Java, however it could depend upon which staff you wished to work on at AWS. Python is likely one of the most generally used languages so it’s a good place to start out.

Java would even be a reasonably good selection for an software operating on AWS, however I don’t wish to have to clarify all of the ideas that I’d want to clarify simply to get began. Java goes to be extra verbose. I’d have to clarify varieties out of the gate…which I’m about to deal with in relation to a submit I simply wrote about XSS in a Lambda perform (keep tuned) however I wished to start out with out it. I’ve addressed varieties on this weblog submit.

Java goes to be extra verbose and require further characters. Python is simply simpler to learn and extra compact when getting began. Working example:

Java:

public String handleRequest(Map<String,String> occasion, Context context)

Python:

def handler(occasion,context):

The great factor about Java in a Lambda perform or Batch is that AWS will embrace the bottom libraries that you must run in these environments so it’s not fairly as a lot of a problem to get configured and arrange I’m guessing. However you continue to must compile your code in keeping with this weblog submit:

However alas, there is no Java compiler in AWS Lambda, so it’s a must to add a compiled perform.

Compiling is typically good in a method and we’ll discover constructing and deploying Docker containers in upcoming posts, however for my small Lambda features and the fast code I want to put in writing, Python appears ample for now.

Often once I’m compiling little safety Lambda features which can be run solely sometimes I’m not positive the power effectivity financial savings could be well worth the time and overhead to change languages — UNLESS I automate all the things and begin growing utilization which I’m working in the direction of. Then the image adjustments. I suppose should you add my little Python Lambdas operating sometimes to everybody else’s it may add up. I’ll let another person try this calculation.

That stated I'm wondering if altering to a renewable power supply could be even higher than making an attempt to spend so much of time re-writing all of the code on the earth. I am making the identical selection in my home. Improve my electrical energy field to assist an electrical water heater and pay big quantities for electrical energy versus putting in gasoline - or is it altering now because of the state of the world? Will gasoline be greater than electrical before later? I may additionally set up a warmth pump water heater (and get an enormous rebate) however it takes up an enormous quantity of area. Or what if I simply set up photo voltaic? Then my power prices scale back dramatically so the price of electrical energy turns into a decrease precedence a part of the equation. Decisions to judge to find out essentially the most cost-effective brief time period and long run resolution. I haven't got that reply but. However what if all the info facilities on the earth switched to various power sources? Yow will discover out what Amazon is doing within the renewable power area right here:
https://aws.amazon.com/blogs/industries/tag/renewable-energy/

Java would undoubtedly be a sooner language (and apparently extra power environment friendly). It will undoubtedly be a stable selection by which to construct an software on AWS. It was once the quickest programming language for me to put in writing however I’m undecided if that’s nonetheless true, although the surroundings setup takes longer.

With golang, it looks as if the strategies for managing libraries prior to now wasn’t absolutely developed. I discovered deployments and package deal administration to be cumbersome. I’m positive that’s higher now however I haven’t had time to finish my weblog submit on the subject. There could be some further overhead for me to make use of it however I should write some code in Goland later within the collection.

As for Rust, I have to get this collection out quick and the important thing factors are the safety ideas, not how briskly or power environment friendly the language is. I don’t know Rust but and the overhead to study it along with what I’m already making an attempt to get out would simply decelerate all the things. I principally don’t have time to make use of Rust instantly. Typically that may be a legitimate selection.

I’m not utilizing Node.js as a result of I don’t like Node.js. That’s it. Though I like JavaScript so much for sure use instances, I discover Node.js to be cumbersome and error inclined and after utilizing many programming languages. I simply don’t just like the syntax or construction. I discover the idea of asynchronous requests attention-grabbing, however it may additionally result in difficult bugs and safety flaws. I not too long ago needed to modify an open supply safety testing device with a bug in it and bolstered my emotions about Node.js. And for many who are involved about power effectivity or any of the benchmarks above it didn’t make the reduce both.

I used .NET (earlier than it was .NET or ASPX or C#) — ASP and Visible Primary extensively over time. The present implementation of C# is a lot better than some previous iterations. Relying on what constructs you utilize there are some protections for reminiscence leaks like leaving database connections and information open — one thing I noticed so much with Java over time. I discover numerous safety points when pentesting ASPX for no matter motive. It might be a nice selection. I’m simply not utilizing it as I have a tendency to love programming languages that run on Linux. It will be a stable selection for somebody already acquainted with the language. AWS even has a weblog devoted to C# on AWS:

I wrote about utilizing .Internet on Lambda right here:

In case your precedence is that you simply wish to use an power environment friendly language from the record above, go for it! You possibly can convert any Python on this weblog collection to every other language you need. You possibly can even translate this code and structure to a different cloud platform.

The purpose of this collection is: SECURITY. I’m making an attempt to clarify and exhibit how to consider safety, a subject I wrote about once I first began instructing my cloud safety courses:

In lots of cybersecurity courses you study bits and items. I’m making an attempt to drag all these bits and items collectively into an entire image in my posts and code:

And to be sincere, I’m making an attempt to get it performed quick. That is just about like a POC and I’m utilizing no matter is quickest to make my factors. However in the end it could morph to one thing fully completely different. For instance, I don’t love utilizing all of the bash I’m utilizing for deploying code. Nonetheless, once you begin with nothing, it’s a must to begin someplace. I’ve a imaginative and prescient for the way all that code will fully change if I can get it performed in time.

This cloud safety structure remains to be a piece in progress on the time of this writing. Comply with for updates…

Teri Radichel

When you favored this story please clap and comply with:

Medium: Teri Radichel or E-mail Listing: Teri Radichel
Twitter: @teriradichel or @2ndSightLab
Requests providers through LinkedIn: Teri Radichel or IANS Analysis

© 2nd Sight Lab 2022

All of the posts on this collection:

____________________________________________

Creator:

Cybersecurity for Executives within the Age of Cloud on Amazon

Want Cloud Safety Coaching? 2nd Sight Lab Cloud Safety Coaching

Is your cloud safe? Rent 2nd Sight Lab for a penetration check or safety evaluation.

Have a Cybersecurity or Cloud Safety Query? Ask Teri Radichel by scheduling a name with IANS Analysis.

Cybersecurity & Cloud Safety Assets by Teri Radichel: Cybersecurity and Cloud safety courses, articles, white papers, shows, and podcasts



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments