Skip to content

Commit ad18b11

Browse files
authoredMar 7, 2024··
Merge pull request #250 from noir-cr/dev
Release v0.13.0
2 parents 654a25c + 52cf056 commit ad18b11

38 files changed

+1951
-78
lines changed
 
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Snapcraft tab Publish
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
snapcraft-releaser:
9+
runs-on: ubuntu-latest
10+
name: snapcraft-releaser
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
platform:
15+
- amd64
16+
- arm64
17+
steps:
18+
- name: Check out Git repository
19+
uses: actions/checkout@v3
20+
21+
- uses: diddlesnaps/snapcraft-multiarch-action@v1
22+
with:
23+
path: stores/snapcraft/stable
24+
architecture: ${{ matrix.platform }}
25+
id: build
26+
27+
- uses: diddlesnaps/snapcraft-review-action@v1
28+
with:
29+
snap: ${{ steps.build.outputs.snap }}
30+
31+
- uses: snapcore/action-publish@master
32+
env:
33+
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAP_STORE_LOGIN }}
34+
with:
35+
snap: ${{ steps.build.outputs.snap }}
36+
release: stable

‎shard.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: noir
2-
version: 0.12.2
2+
version: 0.13.0
33

44
authors:
55
- hahwul <hahwul@gmail.com>

‎snap/snapcraft.yaml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: noir
2+
base: core20
3+
version: 0.13.0
4+
summary: Attack surface detector that identifies endpoints by static analysis.
5+
description: |
6+
Noir is your ally in the quest for digital fortification.
7+
A cutting-edge attack surface detector, it unveils hidden endpoints through meticulous static analysis.
8+
9+
grade: stable # must be 'stable' to release into candidate/stable channels
10+
confinement: strict # use 'strict' once you have the right plugs and slots
11+
license: MIT
12+
13+
apps:
14+
noir:
15+
command: noir
16+
17+
parts:
18+
noir:
19+
source: ./
20+
plugin: nil #crystal
21+
#crystal-channel: latest/stable
22+
override-build: |
23+
curl -fsSL https://crystal-lang.org/install.sh | sudo bash
24+
snapcraftctl pull
25+
shards install
26+
shards build --release
27+
cp ./bin/noir $SNAPCRAFT_PART_INSTALL/
28+
snapcraftctl build
29+
build-packages:
30+
- git
31+
- libssl-dev
32+
- libxml2-dev
33+
- libz-dev
34+
- libyaml-dev
35+
- libpcre2-dev
36+
- libevent-dev
37+
- libgmp-dev
38+
stage-packages:
39+
- libssl1.1
40+
- libxml2
41+
- libevent-2.1-7

‎spec/functional_test/fixtures/go_echo/server.go

+10
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ func main() {
2525
_ = c.FormValue("name")
2626
return c.String(http.StatusOK, "Hello, Pet!")
2727
})
28+
mygroup := e.Group("/admin")
29+
mygroup.GET("/users", func(c echo.Context) error {
30+
return c.String(http.StatusOK, "Hello, Pet!")
31+
})
32+
33+
v1 := mygroup.Group("/v1")
34+
v1.GET("/migration", func(c echo.Context) error {
35+
return c.String(http.StatusOK, "Hello, Pet!")
36+
})
37+
2838
e.Static("/public", "public")
2939
e.Static("/public", "./public2")
3040
e.Static("/public", "/public3")

‎spec/functional_test/fixtures/go_fiber/server.go

+10
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ func main() {
2828
// Websocket logic
2929
}))
3030

31+
mygroup := app.Group("/admin")
32+
mygroup.Get("/users", func(c *fiber.Ctx) error {
33+
return c.SendString(msg) // => ✋ register
34+
})
35+
36+
v1 := mygroup.Group("/v1")
37+
v1.Get("/migration", func(c *fiber.Ctx) error {
38+
return c.SendString(msg) // => ✋ register
39+
})
40+
3141
app.Static("/", "/public")
3242

3343
log.Fatal(app.Listen(":3000"))

‎spec/functional_test/fixtures/go_gin/server.go

+10
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ func main() {
2727
c.String(http.StatusOK, "Submitted data: Username=%s, Password=%s, userAgent=%s", username, password, userAgent)
2828
})
2929

30+
users := r.Group("/group")
31+
users.GET("/users", func(c *gin.Context) {
32+
c.JSON(http.StatusOK, "users")
33+
})
34+
35+
v1 := users.Group("/v1")
36+
v1.GET("/migration", func(c *gin.Context) {
37+
c.JSON(http.StatusOK, "users")
38+
})
39+
3040
r.Static("/public", "public")
3141
r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
3242
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.gradle
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.test;
2+
import javax.servlet.http.HttpServletRequest;
3+
import org.springframework.web.bind.annotation.GetMapping;
4+
import org.springframework.web.bind.annotation.RestController;
5+
6+
@RestController
7+
public class MyController {
8+
9+
@GetMapping("/greet")
10+
public String greet(HttpServletRequest request) {
11+
String name = request.getParameter("name");
12+
if (name == null || name.isEmpty()) {
13+
name = "World";
14+
}
15+
16+
String header = request.getHeader("header");
17+
if (header == null || header.isEmpty()) {
18+
header = "!";
19+
}
20+
return "Hello, " + name + header;
21+
}
22+
}

‎spec/functional_test/fixtures/java_spring/src/ItemController.java

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
package com.test;
12
import org.springframework.web.bind.annotation.*;
3+
import a.b.c.bind.annotation.*;
4+
import org.springframework.c.d.e.*;
25

36
@RestController
47
@RequestMapping("/items")
58
public class ItemController {
69

710
@GetMapping("/{id}")
8-
public Item getItem(@PathVariable Long id) {
11+
public Item getItem(@PathVariable Long id) throws ItemNotFoundException {
912
}
1013

1114
@PostMapping
@@ -23,4 +26,25 @@ public void deleteItem(@PathVariable Long id) {
2326
@GetMapping("/json/{id}", produces = [MediaType.APPLICATION_JSON_VALUE])
2427
public void getItemJson(){
2528
}
29+
}
30+
31+
class Item {
32+
int id;
33+
String name;
34+
35+
public void setId(int _id) {
36+
id = _id;
37+
}
38+
39+
public int getId() {
40+
return id;
41+
}
42+
43+
public void setName(String _name) {
44+
name = _name;
45+
}
46+
47+
public String getName() {
48+
return name;
49+
}
2650
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.test;
2+
import org.springframework.web.bind.annotation.GetMapping;
3+
import org.springframework.web.bind.annotation.RequestParam;
4+
import org.springframework.web.bind.annotation.RestController;
5+
6+
@RestController
7+
public class MyController {
8+
9+
@GetMapping("/greet2")
10+
public String greet2(@RequestParam("myname") String a, @RequestParam("b") int b, String name) {
11+
return "Hello, " + a + b"!";
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.gradle

‎spec/functional_test/testers/go_echo_spec.cr

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ extected_endpoints = [
1717
Endpoint.new("/public/secret.html", "GET"),
1818
Endpoint.new("/public/mob.txt", "GET"),
1919
Endpoint.new("/public/coffee.txt", "GET"),
20+
Endpoint.new("/admin/users", "GET"),
21+
Endpoint.new("/admin/v1/migration", "GET"),
2022
]
2123

2224
FunctionalTester.new("fixtures/go_echo/", {
2325
:techs => 1,
24-
:endpoints => 7,
26+
:endpoints => 9,
2527
}, extected_endpoints).test_all

‎spec/functional_test/testers/go_fiber_spec.cr

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ extected_endpoints = [
1212
]),
1313
Endpoint.new("/secret.html", "GET"),
1414
Endpoint.new("/ws", "GET"),
15+
Endpoint.new("/admin/users", "GET"),
16+
Endpoint.new("/admin/v1/migration", "GET"),
1517
]
1618

1719
FunctionalTester.new("fixtures/go_fiber/", {
1820
:techs => 1,
19-
:endpoints => 4,
21+
:endpoints => 6,
2022
}, extected_endpoints).test_all

‎spec/functional_test/testers/go_gin_spec.cr

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ extected_endpoints = [
1414
Param.new("User-Agent", "", "header"),
1515
]),
1616
Endpoint.new("/public/secret.html", "GET"),
17+
Endpoint.new("/group/users", "GET"),
18+
Endpoint.new("/group/v1/migration", "GET"),
1719
]
1820

1921
FunctionalTester.new("fixtures/go_gin/", {
2022
:techs => 1,
21-
:endpoints => 4,
23+
:endpoints => 6,
2224
}, extected_endpoints).test_all

‎spec/functional_test/testers/java_spring_spec.cr

+12-3
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,21 @@ extected_endpoints = [
1616
# ItemController.java
1717
Endpoint.new("/items/{id}", "GET"),
1818
Endpoint.new("/items/json/{id}", "GET"),
19-
Endpoint.new("/items", "POST"),
20-
Endpoint.new("/items/update/{id}", "PUT"),
19+
Endpoint.new("/items", "POST", [Param.new("id", "", "form"), Param.new("name", "", "form")]),
20+
Endpoint.new("/items/update/{id}", "PUT", [Param.new("id", "", "json"), Param.new("name", "", "json")]),
2121
Endpoint.new("/items/delete/{id}", "DELETE"),
22+
Endpoint.new("/greet", "GET", [
23+
Param.new("name", "", "query"),
24+
Param.new("header", "", "header"),
25+
]),
26+
Endpoint.new("/greet2", "GET", [
27+
Param.new("myname", "", "query"),
28+
Param.new("b", "", "query"),
29+
Param.new("name", "", "query"),
30+
]),
2231
]
2332

2433
FunctionalTester.new("fixtures/java_spring/", {
2534
:techs => 1,
26-
:endpoints => 15,
35+
:endpoints => 17,
2736
}, extected_endpoints).test_all

‎spec/unit_test/analyzer/analyzer_go_echo_spec.cr

+10-9
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,34 @@ require "../../../src/options"
44
describe "analyzer_go_echo" do
55
options = default_options()
66
instance = AnalyzerGoEcho.new(options)
7+
groups = [] of Hash(String, String)
78

89
it "instance.get_route_path - GET" do
9-
instance.get_route_path("e.GET(\"/\", func(c echo.Context) error {").should eq("/")
10+
instance.get_route_path("e.GET(\"/\", func(c echo.Context) error {", groups).should eq("/")
1011
end
1112
it "instance.get_route_path - POST" do
12-
instance.get_route_path("e.POST(\"/\", func(c echo.Context) error {").should eq("/")
13+
instance.get_route_path("e.POST(\"/\", func(c echo.Context) error {", groups).should eq("/")
1314
end
1415
it "instance.get_route_path - PUT" do
15-
instance.get_route_path("e.PUT(\"/\", func(c echo.Context) error {").should eq("/")
16+
instance.get_route_path("e.PUT(\"/\", func(c echo.Context) error {", groups).should eq("/")
1617
end
1718
it "instance.get_route_path - DELETE" do
18-
instance.get_route_path("e.DELETE(\"/\", func(c echo.Context) error {").should eq("/")
19+
instance.get_route_path("e.DELETE(\"/\", func(c echo.Context) error {", groups).should eq("/")
1920
end
2021
it "instance.get_route_path - PATCH" do
21-
instance.get_route_path("e.PATCH(\"/\", func(c echo.Context) error {").should eq("/")
22+
instance.get_route_path("e.PATCH(\"/\", func(c echo.Context) error {", groups).should eq("/")
2223
end
2324
it "instance.get_route_path - HEAD" do
24-
instance.get_route_path("e.HEAD(\"/\", func(c echo.Context) error {").should eq("/")
25+
instance.get_route_path("e.HEAD(\"/\", func(c echo.Context) error {", groups).should eq("/")
2526
end
2627
it "instance.get_route_path - OPTIONS" do
27-
instance.get_route_path("e.OPTIONS(\"/\", func(c echo.Context) error {").should eq("/")
28+
instance.get_route_path("e.OPTIONS(\"/\", func(c echo.Context) error {", groups).should eq("/")
2829
end
2930
it "instance.get_route_path - customContext1" do
30-
instance.get_route_path("customEnv.OPTIONS(\"/\", func(c echo.Context) error {").should eq("/")
31+
instance.get_route_path("customEnv.OPTIONS(\"/\", func(c echo.Context) error {", groups).should eq("/")
3132
end
3233
it "instance.get_route_path - customContext2" do
33-
instance.get_route_path("customEnv.OPTIONS(\"/\", func(myContext echo.Context) error {").should eq("/")
34+
instance.get_route_path("customEnv.OPTIONS(\"/\", func(myContext echo.Context) error {", groups).should eq("/")
3435
end
3536

3637
it "instance.get_static_path - Static" do

‎spec/unit_test/analyzer/analyzer_spring_spec.cr ‎spec/unit_test/analyzer/analyzer_kotlin_spring_spec.cr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
require "../../../src/analyzer/analyzers/analyzer_spring.cr"
1+
require "../../../src/analyzer/analyzers/analyzer_kotlin_spring.cr"
22
require "../../../src/options"
33

44
describe "mapping_to_path" do
55
options = default_options()
6-
instance = AnalyzerSpring.new(options)
6+
instance = AnalyzerKotlinSpring.new(options)
77

88
it "mapping_to_path - GET" do
99
instance.mapping_to_path("@GetMapping(\"/abcd\")").should eq(["/abcd"])
@@ -72,7 +72,7 @@ end
7272

7373
describe "utils func" do
7474
options = default_options()
75-
instance = AnalyzerSpring.new(options)
75+
instance = AnalyzerKotlinSpring.new(options)
7676

7777
it "is_bracket - true" do
7878
instance.is_bracket("{abcd=1234}").should eq(true)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
require "../../../src/detector/detectors/*"
2+
3+
describe "Detect Java Spring" do
4+
options = default_options()
5+
instance = DetectorKotlinSpring.new options
6+
7+
it "build.gradle.kts" do
8+
instance.detect("build.gradle.kts", "'org.springframework.boot' version '2.6.2'").should eq(true)
9+
end
10+
end

0 commit comments

Comments
 (0)
Please sign in to comment.