@@ -10,11 +10,15 @@ import (
10
10
"flag"
11
11
"io"
12
12
"os"
13
+ "time"
13
14
14
15
"github.com/fatih/color"
15
16
"github.com/owasp-amass/amass/v4/config"
16
17
"github.com/owasp-amass/amass/v4/internal/afmt"
17
18
"github.com/owasp-amass/amass/v4/internal/tools"
19
+ assetdb "github.com/owasp-amass/asset-db"
20
+ "github.com/owasp-amass/asset-db/cache"
21
+ "github.com/owasp-amass/asset-db/repository/sqlrepo"
18
22
"github.com/owasp-amass/asset-db/triples"
19
23
)
20
24
@@ -138,6 +142,18 @@ func CLIWorkflow(cmdName string, clArgs []string) {
138
142
_ , _ = afmt .R .Fprintln (color .Error , "Failed to connect with the database" )
139
143
os .Exit (1 )
140
144
}
145
+ // create a new in-memory SQLite database for performance
146
+ cdb , err := assetdb .New (sqlrepo .SQLiteMemory , "" )
147
+ if err != nil {
148
+ _ , _ = afmt .R .Fprintf (color .Error , "Failed to create an in-memory SQLite database: %v\n " , err )
149
+ os .Exit (1 )
150
+ }
151
+ // Create a cache for the database to speed up the association walk
152
+ c , err := cache .New (cdb , db , time .Minute )
153
+ if err != nil {
154
+ _ , _ = afmt .R .Fprintf (color .Error , "Failed to create a cache for the database: %v\n " , err )
155
+ os .Exit (1 )
156
+ }
141
157
142
158
var tris []* triples.Triple
143
159
for _ , tstr := range args .Triples {
@@ -157,14 +173,14 @@ func CLIWorkflow(cmdName string, clArgs []string) {
157
173
os .Exit (1 )
158
174
}
159
175
160
- results , err := triples .Extract (db , tris )
176
+ results , err := triples .Extract (c , tris )
161
177
if err != nil {
162
178
_ , _ = afmt .R .Fprintf (color .Error , "Failed to extract associations: %v\n " , err )
163
179
os .Exit (1 )
164
180
}
165
181
166
- // Marshal with indentation (e.g., 4 spaces)
167
- prettyJSON , err := json .MarshalIndent (results , "" , " " )
182
+ // Marshal with indentation (e.g., 2 spaces)
183
+ prettyJSON , err := json .MarshalIndent (results , "" , " " )
168
184
if err != nil {
169
185
_ , _ = afmt .R .Fprintf (color .Error , "Error marshaling JSON: %v" , err )
170
186
os .Exit (1 )
0 commit comments