Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Dec 11, 2023
1 parent fa7f5f5 commit 1117092
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ <h1>Source code for CveXplore.database.maintenance.DownloadHandler</h1><div clas
<span class="bp">self</span><span class="o">.</span><span class="n">database</span><span class="p">[</span><span class="s2">&quot;info&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">delete_one</span><span class="p">({</span><span class="s2">&quot;db&quot;</span><span class="p">:</span> <span class="n">collection</span><span class="p">})</span>

<span class="k">def</span> <span class="nf">getCPEVersionInformation</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">query</span><span class="p">:</span> <span class="nb">dict</span><span class="p">):</span>
<span class="n">query</span>
<span class="k">return</span> <span class="n">sanitize</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">database</span><span class="p">[</span><span class="s2">&quot;cpe&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="n">query</span><span class="p">))</span>

<span class="k">def</span> <span class="nf">getInfo</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">collection</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span>
Expand Down
33 changes: 25 additions & 8 deletions _modules/CveXplore/database/maintenance/Sources_process.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,27 @@ <h1>Source code for CveXplore.database.maintenance.Sources_process</h1><div clas

<span class="nd">@staticmethod</span>
<span class="k">def</span> <span class="nf">padded_version</span><span class="p">(</span><span class="n">version</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span>
<span class="n">ret_list</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">version</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;.&quot;</span><span class="p">):</span>
<span class="n">ret_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">v</span><span class="p">)</span><span class="si">:</span><span class="s2">05d</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
<span class="k">if</span> <span class="n">version</span> <span class="o">==</span> <span class="s2">&quot;-&quot;</span> <span class="ow">or</span> <span class="n">version</span> <span class="o">==</span> <span class="s2">&quot;&quot;</span><span class="p">:</span>
<span class="k">return</span> <span class="n">version</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">ret_list</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">version</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;.&quot;</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">ret_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="nb">int</span><span class="p">(</span><span class="n">v</span><span class="p">)</span><span class="si">:</span><span class="s2">05d</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
<span class="n">ret_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">v</span><span class="o">.</span><span class="n">rjust</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="s2">&quot;0&quot;</span><span class="p">))</span>

<span class="k">return</span> <span class="s2">&quot;.&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">ret_list</span><span class="p">)</span>
<span class="k">return</span> <span class="s2">&quot;.&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">ret_list</span><span class="p">)</span>

<span class="nd">@staticmethod</span>
<span class="k">def</span> <span class="nf">parse_cpe_version</span><span class="p">(</span><span class="n">cpename</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span>
<span class="n">cpe_list</span> <span class="o">=</span> <span class="n">cpename</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;:&quot;</span><span class="p">)</span>
<span class="n">version_stem</span> <span class="o">=</span> <span class="n">cpe_list</span><span class="p">[</span><span class="mi">5</span><span class="p">]</span>

<span class="k">if</span> <span class="n">cpe_list</span><span class="p">[</span><span class="mi">6</span><span class="p">]</span> <span class="o">!=</span> <span class="s2">&quot;*&quot;</span> <span class="ow">and</span> <span class="n">cpe_list</span><span class="p">[</span><span class="mi">6</span><span class="p">]</span> <span class="o">!=</span> <span class="s2">&quot;-&quot;</span><span class="p">:</span>
<span class="k">return</span> <span class="sa">f</span><span class="s2">&quot;</span><span class="si">{</span><span class="n">version_stem</span><span class="si">}{</span><span class="n">cpe_list</span><span class="p">[</span><span class="mi">6</span><span class="p">]</span><span class="si">}</span><span class="s2">&quot;</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="n">version_stem</span>

<span class="k">def</span> <span class="nf">process_the_item</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">:</span> <span class="nb">dict</span> <span class="o">=</span> <span class="kc">None</span><span class="p">):</span>
<span class="k">if</span> <span class="n">item</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
Expand All @@ -176,13 +189,15 @@ <h1>Source code for CveXplore.database.maintenance.Sources_process</h1><div clas
<span class="k">if</span> <span class="n">t</span><span class="p">[</span><span class="s2">&quot;lang&quot;</span><span class="p">]</span> <span class="o">==</span> <span class="s2">&quot;en&quot;</span><span class="p">:</span>
<span class="n">title</span> <span class="o">=</span> <span class="n">t</span><span class="p">[</span><span class="s2">&quot;title&quot;</span><span class="p">]</span>

<span class="n">version</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">parse_cpe_version</span><span class="p">(</span><span class="n">cpename</span><span class="o">=</span><span class="n">item</span><span class="p">[</span><span class="s2">&quot;cpeName&quot;</span><span class="p">])</span>

<span class="n">cpe</span> <span class="o">=</span> <span class="p">{</span>
<span class="s2">&quot;title&quot;</span><span class="p">:</span> <span class="n">title</span><span class="p">,</span>
<span class="s2">&quot;cpeName&quot;</span><span class="p">:</span> <span class="n">item</span><span class="p">[</span><span class="s2">&quot;cpeName&quot;</span><span class="p">],</span>
<span class="s2">&quot;vendor&quot;</span><span class="p">:</span> <span class="n">item</span><span class="p">[</span><span class="s2">&quot;cpeName&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;:&quot;</span><span class="p">)[</span><span class="mi">3</span><span class="p">],</span>
<span class="s2">&quot;product&quot;</span><span class="p">:</span> <span class="n">item</span><span class="p">[</span><span class="s2">&quot;cpeName&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;:&quot;</span><span class="p">)[</span><span class="mi">4</span><span class="p">],</span>
<span class="s2">&quot;version&quot;</span><span class="p">:</span> <span class="n">item</span><span class="p">[</span><span class="s2">&quot;cpeName&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;:&quot;</span><span class="p">)[</span><span class="mi">5</span><span class="p">],</span>
<span class="s2">&quot;padded_version&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">padded_version</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s2">&quot;cpeName&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;:&quot;</span><span class="p">)[</span><span class="mi">5</span><span class="p">]),</span>
<span class="s2">&quot;version&quot;</span><span class="p">:</span> <span class="n">version</span><span class="p">,</span>
<span class="s2">&quot;padded_version&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">padded_version</span><span class="p">(</span><span class="n">version</span><span class="p">),</span>
<span class="s2">&quot;stem&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">stem</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s2">&quot;cpeName&quot;</span><span class="p">]),</span>
<span class="s2">&quot;cpeNameId&quot;</span><span class="p">:</span> <span class="n">item</span><span class="p">[</span><span class="s2">&quot;cpeNameId&quot;</span><span class="p">],</span>
<span class="s2">&quot;lastModified&quot;</span><span class="p">:</span> <span class="n">parse_datetime</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s2">&quot;lastModified&quot;</span><span class="p">],</span> <span class="n">ignoretz</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span>
Expand Down Expand Up @@ -466,6 +481,8 @@ <h1>Source code for CveXplore.database.maintenance.Sources_process</h1><div clas
<span class="p">},</span>
<span class="p">}</span>

<span class="n">query</span><span class="p">[</span><span class="s2">&quot;deprecated&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span>

<span class="k">return</span> <span class="n">query</span>

<span class="nd">@staticmethod</span>
Expand Down

0 comments on commit 1117092

Please sign in to comment.