@@ -2,6 +2,9 @@ require "rubygems"
2
2
require "bundler/setup"
3
3
require "stringex"
4
4
5
+ # Load Rake tasks from the tasks/ directory
6
+ Dir [ "tasks/**/*.rake" ] . each { |task | load task }
7
+
5
8
## -- Rsync Deploy config -- ##
6
9
# Be sure your public key is listed in your server's ~/.ssh/authorized_keys file
7
10
ssh_user = "user@domain.com"
@@ -380,70 +383,4 @@ desc "list tasks"
380
383
task :list do
381
384
puts "Tasks: #{ ( Rake ::Task . tasks - [ Rake ::Task [ :list ] ] ) . join ( ', ' ) } "
382
385
puts "(type rake -T for more detail)\n \n "
383
- end
384
-
385
- #############################
386
- # Rebuild advisory Markdown #
387
- #############################
388
- require 'net/http'
389
-
390
- desc "sync with ruby-advisory-db and rebuild Markdown files"
391
- task :sync_advisories do
392
- sh "git submodule update"
393
-
394
- Rake ::FileList [ "ruby-advisory-db/gems/**/*.yml" ] . each do |advisory |
395
- yaml = YAML . load_file ( advisory )
396
-
397
- cve = "CVE-" + yaml [ 'cve' ]
398
- title = yaml [ 'title' ] . gsub ( /\s +/m , ' ' )
399
-
400
- title = "#{ cve } : #{ title } "
401
- slug = title . downcase . gsub ( /[^\w ]+/ , '-' )
402
-
403
- puts "Processing: #{ title } "
404
-
405
- if yaml [ 'url' ] [ 'osvdb.org' ]
406
- osvdb_entry = Net ::HTTP . get URI ( yaml [ 'url' ] )
407
- date = osvdb_entry [ /(\d {4}-\d {2}-\d {2})\< \/ td/ , 1 ]
408
- else
409
- nvd_entry = Net ::HTTP . get URI ( "http://web.nvd.nist.gov/view/vuln/detail?vulnId=#{ cve } " )
410
- matches = nvd_entry . match ( /(\d {2})\/ (\d {2})\/ (\d {4})\< \/ div/ )
411
-
412
- if matches
413
- date = sprintf ( "%04d-%02d-%02d" , Integer ( matches [ 3 ] ) , Integer ( matches [ 1 ] ) , Integer ( matches [ 2 ] ) )
414
- else
415
- puts "Can't determine date for: #{ title } "
416
- date = "#{ yaml [ 'cve' ] [ /\d {4}/ ] } -01-01"
417
- end
418
- end
419
-
420
- filename = "#{ date } -#{ slug } .markdown"
421
- contents = <<-MARKDOWN
422
- ---
423
- layout: post
424
- title: "#{ title } "
425
- date: #{ date }
426
- comments: false
427
- categories: [#{ yaml [ 'gem' ] } #{ ",#{ yaml [ 'framework' ] } " if yaml [ 'framework' ] } ]
428
- ---
429
-
430
- ### CVE ID
431
-
432
- * #{ yaml [ 'url' ] ? "[#{ cve } ](#{ yaml [ 'url' ] } )" : cve }
433
-
434
- ### GEM NAME
435
-
436
- * #{ yaml [ 'gem' ] }
437
- #{ "\n ### FRAMEWORK\n \n * #{ yaml [ 'framework' ] } \n " if yaml [ 'framework' ] }
438
- ### PATCHED VERSIONS
439
-
440
- #{ yaml [ 'patched_versions' ] . map { |v | "* \` #{ v } \` " } . join ( "\n " ) }
441
-
442
- ### DESCRIPTION
443
-
444
- #{ yaml [ 'description' ] }
445
- MARKDOWN
446
-
447
- File . open ( "source/_posts/#{ filename } " , "w" ) { |file | file << contents }
448
- end
449
386
end
0 commit comments