teleren/devto huggingface dataset:
Como pegar os resultados do DAST em um pipeline?
Tags: veracode, security, powershell, tutorial
Published: 2023-03-04 01:56:06

Vamos organizar esse projeto em duas partes, sendo a primeira os requisitos e a segunda o processo de fato. 

Para a pipeline em si, estou utilizando uma imagem Windows e criei um grupo de variáveis onde armazenei as duas [credenciais de API](https://dev.to/m3corp/credenciais-da-veracode-340m), pode saber mais sobre elas aqui, utilizando os nomes padrões **veracode_api_key_id** e **veracode_api_key_secret**:
```
trigger:
- main

variables:
- group: Veracode-DAST
- name: veracodeAppName
  value: MSDN.Gruyere

pool:
  vmImage: windows-latest
```
Na variável **veracodeAppName**, colocamos o nome do perfil de aplicação onde vinculamos o resultado do DAST

Para os requisitos, precisamos ter o HTTPIE e o autenticador da Veracode, podemos instalar eles via CLI:

```
steps:
- task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: |
      pip install httpie
      pip install veracode-api-signing
  displayName: 'Install Requirements'
```

Para receber os resultados, vamos utilizar uma combinação de chamadas de API com o HTTPIE e o tratamento das informações via Powershell. O nosso fluxo é:
1. Recebemos o nome do perfil
2. Usamos ele para obter o código da aplicação/GUID
3. Filtramos a ultima analise DAST completa
4. Validamos se nela existem falhas, e caso existam, exibimos elas

Traduzindo para o Powershell, criamos um script chamado DAST-Resultados.ps1 com os seguintes comandos:
```
[CmdletBinding()]
param (
    [Parameter()]
    $veracodeAppName
)

# Recebe os detalhes do perfil de App
$infosApp = http --auth-type=veracode_hmac GET "https://api.veracode.com/appsec/v1/applications/?name=$veracodeAppName" | ConvertFrom-Json
$guidApp = $infosApp._embedded.applications.guid

# Recebe os scans DAST
$historicoDAST = http --auth-type=veracode_hmac GET "https://api.veracode.com/appsec/v2/applications/$guidApp/findings?scan_type=DYNAMIC&violates_policy=TRUE" | ConvertFrom-Json
$falhasDAST = $historicoDAST._embedded.findings

# Valida se existe alguma falha que viola a politica
$totalFalhas = $falhasDAST.count
if ($totalFalhas -gt 0) {
    Write-Host "Foram encontradas falhas nesse scan"
    $falhasDAST
    Write-Error -Message "Total de Falhas: $totalFalhas" -Category SecurityError
}
```
No meu caso, salvei ele dentro da raiz do repositório. 

Voltando ao nosso pipeline, podemos iniciar o script dessa forma:
```
- task: PowerShell@2
  inputs:
    filePath: 'DAST-Resultados.ps1'
    arguments: '$(veracodeAppName)'
  displayName: 'Resultados DAST'
```

No final, nosso script completo fica:
```
# O script PS1 está na seção de SOs/Windows
trigger:
- main

variables:
- group: Veracode-DAST
- name: veracodeAppName
  value: MSDN.Gruyere

pool:
  vmImage: windows-latest

steps:
- task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: |
      pip install httpie
      pip install veracode-api-signing
  displayName: 'Install Requirements'

- task: PowerShell@2
  inputs:
    filePath: 'DAST-Resultados.ps1'
    arguments: '$(veracodeAppName)'
  displayName: 'Resultados DAST'
```
Creating sprites and playing a basic game
Tags: gamedev, beginners, playdate, lua
Published: 2023-03-04 00:27:51

In the last article I inspected each line of the example `main.lua` file provided in [Inside Playdate](https://sdk.play.date/1.13.1/Inside%20Playdate.html#basic-playdate-game).

Of particular interest were the lines that referenced images:
```
local playerImage = gfx.image.new("Images/playerImage")

local backgroundImage = gfx.image.new( "Images/background" )
```

How do I make images that will display on the Playdate's screen?

What exactly are `sprites`?

## Finding free online sprite-making software
A couple of Google searches and list-based articles later, I found a solution: [Piskel](https://www.piskelapp.com/p/create/sprite)

After a few minutes scanning the interface and just drawing silly nonsense, I made this:
![Player image in Piskel](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8oeqb58nnmwc5uo8hmlc.png)

I exported as a PNG file to preserve the transparency.

Next, I needed a background image.

## Making a background image
The document mentioned that the center of the screen is `200,120`.

I take that to mean the screen's pixel grid is 400 x 240.

So, I opened my go-to design tool, Sketch, created an artboard of that size, and used the pencil tool to draw a scrappy landscape:
![Background in Sketch](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9f8thsvkrz81f8rloomh.png)

I exported it as a PNG as well.

## Compiling and running the `game.pdx` file
I replaced the contents of my sample game's `main.lua` file with the one from the documentation.

I ran the compile command.

And I opened the `game.pdx` file in the Playdate Simulator.

Good news:
- I saw the player image
- I could move the player image

Bad news:
- I didn't see the background image

## Mystery solved: line color
- I went back into Sketch
- I selected all the lines I just drew
- Their border color was light gray

That's probably why I didn't see the image: gray became white...or just didn't render!

I updated all lines to be black.

I reloaded the `game.pdx` file into the Simulator.

No change.

I re-compiled the game.

Reloaded it.

I now saw the background image!

![Game running successfully](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2dabqqoarqkdd2jzv884.gif)

## Short but successful
- I accomplished my goal: play the game with images I made
- I learned to check line colors for a 1-bit screen
- I discovered a great tool for making sprites

More documentation studying, coming up next!
Update rails 5.2 to 6 (THOR MERGE solution included)
Published: 2023-03-04 00:15:25

Summary of steps

- gem 'rails', '~> 6.0'
- bundle update rails
- rails app:update
	     if you get a merge tool error "Please specify merge tool to `THOR_MERGE` env." Follow these steops:
		exit the update process
	          run:  $  THOR_MERGE=code rails app:update (selects vs code as your merge tool)
		 run rails app:update
	      select 'm' to merge files

- Uncomment defaults in new_framework_defaults_6_0.rb
- Go to new framework_defaults_6_0.rb I suggest to read the comments - there are several new defaults which are recommended to uncomment once you are confident that your app is stable on Rails 6. I did as it was suggested.
- Delete new framework_defaults_6_0.rb when app is tested and working.

src - https://fullstackheroes.com/tutorials/rails/upgrade-to-rails-6/
ChatGPT - Complex Coding Challenges: 7 KYU
Tags: javascript, c, sql, chatgpt
Published: 2023-03-03 23:37:24

Hello there!

Today we are back with the second article of this series in which we put ChatGPT to the test and without me waffling on any further, lets take a look at the challenge.

Here is the challenge [Sum of odd numbers](https://www.codewars.com/kata/55fd2d567d94ac3bc9000064)

Followed by the instructions and examples:

```bash
Given the triangle of consecutive odd numbers:

             1
          3     5
       7     9    11
   13    15    17    19
21    23    25    27    29
...
Calculate the sum of the numbers in the nth row of this triangle (starting at index 1) e.g.: (Input --> Output)

1 -->  1
2 --> 3 + 5 = 8
```

Not a great deal to go off of, but simple enough that ChatGPT should not struggle... I think.

**Solving it in JavaScript**

```js
function rowSumOddNumbers(n) {
	 // Calculate the starting number for the nth row
  let start = (n * (n - 1)) + 1;
  
  // Calculate the sum of the numbers in the nth row
  let sum = 0;
  
  for (let i = 0; i < n; i++) {
    sum += start + (2 * i);
  }
  
  return sum;
}
```

Running the above code makes all tests pass!

**Solving it in C**

```c
#include <inttypes.h>

uint64_t rowSumOddNumbers(uint32_t n) {
    uint64_t start_num = 1, sum = 0;

    // Calculate the starting number of the nth row
    for (uint32_t i = 1; i < n; i++) {
        start_num += 2 * i;
    }

    // Calculate the sum of the numbers in the nth row
    for (uint32_t i = 0; i < n; i++) {
        sum += start_num + 2 * i;
    }

    return sum;
}
```

It took 2 attempts for the C implementation to be correct however I think the issue was not starting a new prompt with ChatGPT

**Solving it in SQL**

```sql
SELECT SUM(nums.num) as sum_of_row
FROM 
  (SELECT ((n-1)*(n-1)+1) as num 
   FROM nums WHERE n = [input row number]) as nums
UNION ALL
SELECT SUM(nums.num) as sum_of_row
FROM 
  (SELECT ((n-1)*(n-1)+1) as num 
   FROM nums WHERE n = [input row number]) as nums
  JOIN 
  (SELECT ((n-1)*(n-1)+1) as num 
   FROM nums WHERE n = [input row number]-1) as nums_prev
  ON nums_prev.num < nums.num AND nums_prev.num % 2 = 1
```

After many attempts, I could not get ChatGPT to understand what it needed to do in order to pass this challenge.

Even before testing the SQL solution I have a feeling it is wrong because it is writing very verbose solutions to what I feel should be quite trivial at this point.

Maybe we will continue with SQL, maybe not. It depends on whether or not I figure out this current challenge!
How to use nodemon with VSCode debugger?
Tags: node, vscode, beginners, tutorial
Published: 2023-03-03 23:33:11

## Table Of Contents
  * [Intro](#chapter-1)
  * [Step by step](#chapter-2)
  * [Demo](#chapter-3)

### Intro <a name="chapter-1"></a>

As a developer, you know that debugging is a crucial aspect of your workflow. It helps you identify and fix issues in your code, and ultimately improve your application's performance. However, the process of debugging can be time-consuming and tedious, especially if you have to manually restart your application every time you make a change. This is where Nodemon and Visual Studio Code Debugger come in handy.

Nodemon is a tool that helps you automate the process of restarting your Node.js application whenever you make changes to your code. It monitors your application for changes and automatically restarts it when it detects any modifications. This saves you a lot of time and effort, as you don't have to manually stop and start your application every time you make changes.

Visual Studio Code Debugger, on the other hand, is an integrated development environment (IDE) that provides a powerful debugging experience for Node.js applications. It allows you to set breakpoints, step through your code, and inspect variables and objects at runtime.

VSCode provides a configuration for nodemon (see image below), but I couldn't use it at first, so I had to update to the package path installed in "node_modules".

This is because the "nodemon" package is installed in the project, not globally.

---

### So how do I do it? <a name="chapter-2"></a>

The steps to integrate nodemon in VSCode debugger are:

1. Install `nodemon` as development dependency in your repository: 

```bash
npm install -D nodemon
# or
npm install --save-dev nodemon
```

2. Configure the VSCode "launch.json" as follows, updating the value of `runtimeExecutable`: 

```jsonc
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "nodemon",
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen",
      "program": "${workspaceFolder}/app.js",
      "request": "launch",
      "restart": true,
      // "runtimeExecutable": "nodemon", /* ORIGINAL VALUE */
      "runtimeExecutable": "${workspaceFolder}/node_modules/nodemon/bin/nodemon.js",
      "type": "node"
    }
  ]
}
```

---

### And it done! <a name="chapter-3"></a>

For your convenience I created this demo repository: [andersonbosa/nodemon-vscode-tutorial][repo]

{% embed https://github.com/andersonbosa/nodemon-vscode-tutorial %}

---

Do you know how to integrate other languages with the VSCode Debugger? Please share in the comments! All kinds of contributions are very welcome and appreciated.


[repo]: https://github.com/andersonbosa/nodemon-vscode-tutorial
Enable Multiple SSO Connections from Multiple Identity Providers to Your Zendesk with Datawiza
Published: 2023-03-03 23:29:08

Streamline your authentication process and make it easier for users to access your Zendesk with Datawiza’s Identity Brokering service. Our service allows you to enable multiple Single Sign-On (SSO) connections with multiple identity providers like Microsoft Azure AD, Okta, and Google Workspace.

With just a few clicks, you can seamlessly integrate multiple SSO connections to your Zendesk, making it more secure and efficient for users to log in. Datawiza’s advanced Identity Brokering service acts as a bridge between multiple identity providers and your Zendesk to enable SSO.

https://www.youtube.com/watch?v=HYrc-cPtBfk


The post [Enable Multiple SSO Connections from Multiple Identity Providers to Your Zendesk with Datawiza](https://www.datawiza.com/videos/enable-multiple-sso-connections-from-multiple-identity-providers-to-your-zendesk-with-datawiza/) appeared first on [Datawiza](https://www.datawiza.com).
Configure multiple ssh credentials with git
Tags: git, javascript, tutorial, productivity
Published: 2023-03-03 22:49:09

If you wish to configure multiple SSH keys on your computer because you use it for both work and personal projects, you need to set up different users in your repository. 

Assuming that the first key is referred to as a “personal_key” and the second is referred to as a “work_key," both of which have their own public files extensions, you can edit the config file (~/.ssh/config) to include the following details.

```
Host work-github.com
	HostName github.com
	User git
	IdentityFile ~/.ssh/work_key
Host github.com
	HostName github.com
	User git
	IdentityFile ~/.ssh/personal_key
```

Once saved, go to the working folder where you are running this project from (for example home/dashpy/work) and use command git remote -v. This should bring up something similar to:

```
$ git remote -v
origin	git@github.com:dashpy/insight.git (fetch)
origin	git@github.com:dashpy/insight.git (push)
```


We want to change that and tell git that when I'm working in this work project use my work ssh key, so to do that we type

```
git remote set-url origin git@work-github.com:Company/product.git

```
Which will tell Git that it should use your work SSH key when this particular working project is used.

The end.
Day 706 : All Good
Tags: hiphop, code, coding, lifelongdev
Published: 2023-03-03 22:39:22

_liner notes_:
- Professional : Spent the day refactoring code and listening to De La Soul. Pretty chill.

- Personal : Last night, I went through some tracks for the radio show, preordered some stuff from WeAreDeLaSoul.com. Had an issue with a couple of downloads and wrote the support email. Hopefully, I'll hear back soon. Watch the De La Soul event livestream while working on my side project. Got a lot of stuff done on the form to add events and I got more insight into what data I'll need to save.

![Above the clouds over Cape Town, South Africa at sunset](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3i363jycjle2b06sf5va.jpg)

Going to finish putting together the radio show for tomorrow. Since I got a bunch of stuff done the past weeks, shouldn't have too much left to do. Then I want to get the settings saved in my side project and pull it from the front end. Looks like I'll be able to go into the station to do the radio show since basketball season is over. I'll double check again tomorrow before I leave to make sure it's all good.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube TH0q9eGNXBc %}
How to Upload file in S3 using Different Storage classes in Golang
Tags: go, aws, s3, s3glacier
Published: 2023-03-03 22:07:33

## Introduction
I have written blog post in the previous post on using [various storage classes in S3](https://dev.to/ankitmalikg/aws-s3-storage-classes-1g6c).

So, here in this post I will show you that how you can upload any file to S3 using different storage classes.



## Code
```go
package main

import (
	"encoding/csv"
	"fmt"
	"math/rand"
	"os"

	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/aws/aws-sdk-go/service/glacier"
	"github.com/aws/aws-sdk-go/service/s3/s3manager"
)

func main() {
	// Generate random CSV data
	data := [][]string{
		{"name", "age", "gender"},
		{"Alice", fmt.Sprint(rand.Intn(50)), "female"},
		{"Bob", fmt.Sprint(rand.Intn(50)), "male"},
		{"Charlie", fmt.Sprint(rand.Intn(50)), "male"},
		{"David", fmt.Sprint(rand.Intn(50)), "male"},
	}

	// Create a new CSV file
	file, err := os.Create("random.csv")
	if err != nil {
		panic(err)
	}
	defer file.Close()

	// Write CSV data to file
	writer := csv.NewWriter(file)
	defer writer.Flush()
	for _, row := range data {
		err := writer.Write(row)
		if err != nil {
			panic(err)
		}
	}

	// Upload file to S3 with GLACIER storage class
	bucket := "my-bucket"
	region := "us-east-1"
	key := "random.csv"
	uploader := s3manager.NewUploader(session.Must(session.NewSession(&aws.Config{
		Region: aws.String(region),
	})))
	_, err = uploader.Upload(&s3manager.UploadInput{
		Bucket:       &bucket,
		Key:          &key,
		Body:         file,
		ACL:          aws.String("private"),
		StorageClass: aws.String("GLACIER"),
	})
	if err != nil {
		panic(err)
	}

	// Archive file to S3 Glacier Service
	svc := glacier.New(session.Must(session.NewSession(&aws.Config{
		Region: aws.String(region),
	})))
	vaultName := "my-vault"
	_, err = svc.UploadArchive(&glacier.UploadArchiveInput{
		Body:      file,
		VaultName: aws.String(vaultName),
	})
	if err != nil {
		panic(err)
	}

	fmt.Println("File uploaded to S3 with Standard-IA storage class and archived to S3 Glacier")
}

```


## Various storage classes placeholder
These are different strings for storage class which can be passed to store the data in S3 in different classes.


```yaml
STANDARD: Standard storage class for frequently accessed data.
STANDARD_IA: Standard-Infrequent Access storage class for infrequently accessed data.
ONEZONE_IA: One Zone-Infrequent Access storage class for infrequently accessed data that can be recreated.
INTELLIGENT_TIERING: Intelligent Tiering storage class for data with unknown or changing access patterns.
GLACIER: Glacier storage class for long-term data archival.
DEEP_ARCHIVE: Deep Archive storage class for long-term data archival with the lowest cost.
```
I Read An Article On Burnout, And Now I'm Scared
Tags: beginners, webdev, discuss
Published: 2023-03-03 21:37:30

[](https://alistapart.com/article/thats-not-my-burnout/)

I decided to read "That's Not My Burnout", as someone who has recently discovered the possibility of having ADHD and/or ASD, a lot of things about myself have started to make sense. Some of those things being, hyperfixations, stimming and autistic inertia. The last one is my biggest concern. Sometimes it is hard to stop, or in this case _begin_. It is not possible to find motivation to do somethiing or get simple or hard tasks completed, making completing tasks a complete gamble. And as the article mentioned, a lot of people felt the same way at the height of the pandemic. Burnout was a constant for me, I dropped all of my classes, and some days did not get out of bed at all. I had zero motivation to do a single thing except wake up, eat and sleep. But there were also some days where I could do one thing from sun up to sun down. I could write or draw all day, do my nails,  play video games, and on the rare occasion - clean. I am excited to learn how to code, I want to be in control of my schedule, make something I'm proud of, work from home and have a reliable paycheck for once. But the constant fear of having no motivation is intimidating. I don't know if anyone else feels this way, or if a successful developer has felt this way, and it makes me wonder how they pushed through it.
FREE AWS Cloud Project Bootcamp Week 2 Part 1
Tags: aws, cloud, awscommunity, 100daysofcloud
Published: 2023-03-03 21:32:12

[62/100] #100DaysOfCloud Today, I completed a part of the Week 2 of the FREE AWS Cloud Project Bootcamp by Andrew Brown.

Here's what I completed:
- Watch Week 2 Live-Stream Video.
- Instrument our backend flask application to use Open Telemetry (OTEL) with Honeycomb.io as the provider.
- Run queries to explore traces within Honeycomb.io.
- Watched Ashish's Week 2 - Observability Security Considerations which also explains Observability vs Monitoring in AWS.

[GitHub](https://github.com/aaditunni/100DaysOfCloud/blob/main/Journey/062/Readme.md)

You can watch the Bootcamp through this YouTube playlist : [FREE AWS Cloud Project Bootcamp playlist](https://youtube.com/playlist?list=PLBfufR7vyJJ7k25byhRXJldB5AiwgNnWv)
How to limit input length or lines in React-codemirror
Tags: react, javascript, codemirror
Published: 2023-03-03 17:47:28

Codemirror is a powerful library that allows users to integrate a production-ready code editor into their projects. It’s a huge library with great thorough documentation, but it’s not something you can read in one sitting. 

## TLDR;

How to limit the length of doc:
```jsx
 const lengthLimit = useCallback((tr: any): boolean => {
    // NOTE: limiting the length to 100 characters.
    return tr.startState.doc.length + tr.newDoc.length < 200;
  }, []);

<CodeMirror
  value={value}
  extensions={[
    EditorState.changeFilter.of(lengthLimit)
  ]}
  onChange={(value) => setValue(value)}
/>
```
Source [[1]](https://codesandbox.io/s/react-codemirror-example-codemirror-6-forked-kylrmk?file=/src/App.tsx), [[2]](https://github.com/uiwjs/react-codemirror/issues/371)

Similarly, this is how you limit line numbers.

```jsx
const handleLengthLimit = () => {
   // doc will only update with the newDoc’s line number <= 10
   return tr.newDoc.lines <= 10;
}

<CodeMirror
      extensions={[                  
          EditorState.changeFilter.of(handleLengthLimit),
      ]}
      onChange={handleChange}                      
/>
```


## In-depth

[React-codemirror](https://github.com/uiwjs/react-codemirro) is the most widely used React component for Codemirror. It uses Codemirror 6 behind the scene. However, it has lots of known limitations because Codemirror does not behave in a React way. (It was there before React.)

As of Mar, 2023, React-codemirror editor is currently a [uncontrolled component](https://reactjs.org/docs/uncontrolled-components.html)  

So when most of React Developer would want to achieve something like this:


> User input -> update input state -> mutate input state using useMemo or useEffect -> update input state -> rerender with thew new input


The above wouldn’t work since the component is uncontrolled. So the work around is going to be:


> User input -> intercept input and do your stuff with EditorState.changeFilter or EditorState.transactionFilter -> update state -> rerender


If you’re using it for a production feature at your work. I highly recommend you to do a DIY React component by following [this article.](https://www.codiga.io/blog/revisiting-codemirror-6-react-implementation/)



## About
If you run into the same problem and this article helped you a bit please:
 follow my [Github Repo](https://github.com/the-watchmaker) 
And check out my silly project [Typing Brain](https://github.com/the-watchmaker/typingbrain)
Meet Jarvis: Your Personal AI Assistant for Hands-Free Information Retrieval - Speak Your Queries and Get Instant Answers!
Tags: openai, gpt3, python
Published: 2023-03-03 21:31:24

Introducing my new AI-powered personal assistant, Jarvis!

Check out the project on my GitHub repository: https://github.com/felipeOliveira-1/voice_assistant_openai

Jarvis uses OpenAI's GPT-3 to generate natural language responses to your questions, making it easy to get answers to your queries without having to type them out. Simply speak your question into the microphone, and Jarvis will do the rest.

Jarvis also features speech-to-text transcription and text-to-speech capabilities, allowing for a completely hands-free experience. And with the ability to easily customize Jarvis's voice and language settings, you can create a truly personalized assistant that fits your unique needs.

I invite you to give Jarvis a try and see how it can make your life easier. And if you're interested in contributing to the project, I welcome your input and ideas. Let's work together to make Jarvis the best personal assistant it can be!